Skip to content

Commit

Permalink
Add new FEVM actors to the registry
Browse files Browse the repository at this point in the history
  • Loading branch information
Aayush Rajasekaran authored and Aayush Rajasekaran committed Jan 2, 2023
1 parent a4d93d7 commit e1aca24
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 8 deletions.
31 changes: 31 additions & 0 deletions chain/actors/builtin/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import (
account10 "github.com/filecoin-project/go-state-types/builtin/v10/account"
cron10 "github.com/filecoin-project/go-state-types/builtin/v10/cron"
datacap10 "github.com/filecoin-project/go-state-types/builtin/v10/datacap"
eam10 "github.com/filecoin-project/go-state-types/builtin/v10/eam"
embryo10 "github.com/filecoin-project/go-state-types/builtin/v10/embryo"
ethaccount10 "github.com/filecoin-project/go-state-types/builtin/v10/ethaccount"
evm10 "github.com/filecoin-project/go-state-types/builtin/v10/evm"
_init10 "github.com/filecoin-project/go-state-types/builtin/v10/init"
market10 "github.com/filecoin-project/go-state-types/builtin/v10/market"
miner10 "github.com/filecoin-project/go-state-types/builtin/v10/miner"
Expand Down Expand Up @@ -265,6 +269,7 @@ func MakeRegistry(av actorstypes.Version) []RegistryEntry {
methods: datacap9.Methods,
state: new(datacap9.State),
})

}
}

Expand Down Expand Up @@ -343,6 +348,32 @@ func MakeRegistry(av actorstypes.Version) []RegistryEntry {
methods: datacap10.Methods,
state: new(datacap10.State),
})

case manifest.EvmKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: evm10.Methods,
state: new(evm10.State),
})
case manifest.EamKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: eam10.Methods,
state: nil,
})
case manifest.EmbryoKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: embryo10.Methods,
state: nil,
})
case manifest.EthAccountKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: ethaccount10.Methods,
state: nil,
})

}
}

Expand Down
32 changes: 32 additions & 0 deletions chain/actors/builtin/registry.go.template
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ import (
{{if (ge . 9)}}
datacap{{.}} "github.com/filecoin-project/go-state-types/builtin/v{{.}}/datacap"
{{end}}
{{if (ge . 10)}}
evm{{.}} "github.com/filecoin-project/go-state-types/builtin/v{{.}}/evm"
eam{{.}} "github.com/filecoin-project/go-state-types/builtin/v{{.}}/eam"
embryo{{.}} "github.com/filecoin-project/go-state-types/builtin/v{{.}}/embryo"
ethaccount{{.}} "github.com/filecoin-project/go-state-types/builtin/v{{.}}/ethaccount"
{{end}}
{{end}}
"github.com/filecoin-project/go-state-types/cbor"
rtt "github.com/filecoin-project/go-state-types/rt"
Expand Down Expand Up @@ -174,6 +180,32 @@ func MakeRegistry(av actorstypes.Version) []RegistryEntry {
methods: datacap{{.}}.Methods,
state: new(datacap{{.}}.State),
}){{end}}
{{if (ge . 10)}}
case manifest.EvmKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: evm{{.}}.Methods,
state: new(evm{{.}}.State),
})
case manifest.EamKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: eam{{.}}.Methods,
state: nil,
})
case manifest.EmbryoKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: embryo{{.}}.Methods,
state: nil,
})
case manifest.EthAccountKey:
registry = append(registry, RegistryEntry{
code: codeID,
methods: ethaccount{{.}}.Methods,
state: nil,
})
{{end}}
}
}
{{end}}
Expand Down
9 changes: 4 additions & 5 deletions chain/vm/invoker.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,17 +284,16 @@ func DecodeParams(b []byte, out interface{}) error {
}

func DumpActorState(i *ActorRegistry, act *types.Actor, b []byte) (interface{}, error) {
// Account & Embryo code special case
if builtin.IsAccountActor(act.Code) || builtin.IsEmbryoActor(act.Code) {
return nil, nil
}

actInfo, ok := i.actors[act.Code]
if !ok {
return nil, xerrors.Errorf("state type for actor %s not found", act.Code)
}

um := actInfo.vmActor.State()
if um == nil {
// TODO: I would like to assert that we have the empty object here
return nil, nil
}
if err := um.UnmarshalCBOR(bytes.NewReader(b)); err != nil {
return nil, xerrors.Errorf("unmarshaling actor state: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ require (
github.com/filecoin-project/go-legs v0.4.4
github.com/filecoin-project/go-padreader v0.0.1
github.com/filecoin-project/go-paramfetch v0.0.4
github.com/filecoin-project/go-state-types v0.10.0-alpha.7
github.com/filecoin-project/go-state-types v0.10.0-alpha-6.0.20230102223901-51c56a8c7393
github.com/filecoin-project/go-statemachine v1.0.2
github.com/filecoin-project/go-statestore v0.2.0
github.com/filecoin-project/go-storedcounter v0.1.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,8 @@ github.com/filecoin-project/go-state-types v0.1.0/go.mod h1:ezYnPf0bNkTsDibL/psS
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.10.0-alpha.7 h1:CnHwzDJpeixx1FLHtlp3iDv2j346qFDYa0w99mSt9A4=
github.com/filecoin-project/go-state-types v0.10.0-alpha.7/go.mod h1:FPgQE05BFwZxKw/vCuIaIrzfJKo4RPQQMMPGd43dAFI=
github.com/filecoin-project/go-state-types v0.10.0-alpha-6.0.20230102223901-51c56a8c7393 h1:AW1Dq8iRreuROu+A4MzOXCeHZ7rg/0Qeo+mZEcDt7aQ=
github.com/filecoin-project/go-state-types v0.10.0-alpha-6.0.20230102223901-51c56a8c7393/go.mod h1:FPgQE05BFwZxKw/vCuIaIrzfJKo4RPQQMMPGd43dAFI=
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 h1:421SSWBk8GIoCoWYYTE/d+qCWccgmRH0uXotXRDjUbc=
github.com/filecoin-project/go-statemachine v1.0.2/go.mod h1:jZdXXiHa61n4NmgWFG4w8tnqgvZVHYbJ3yW7+y8bF54=
Expand Down

0 comments on commit e1aca24

Please sign in to comment.