Skip to content

Commit

Permalink
fix: make actors gen
Browse files Browse the repository at this point in the history
- generate v10 actor state accessors
- update integrated state processor actor version
  • Loading branch information
frrist committed Jan 18, 2023
1 parent 3bdd537 commit fe11b3f
Show file tree
Hide file tree
Showing 28 changed files with 228 additions and 463 deletions.
202 changes: 0 additions & 202 deletions chain/actors/builtin/builtin.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,12 @@ import (

builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"

"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/builtin"
"github.com/filecoin-project/go-state-types/proof"

"github.com/filecoin-project/lotus/chain/actors"

smoothingtypes "github.com/filecoin-project/go-state-types/builtin/v8/util/smoothing"
minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner"
)

var SystemActorAddr = builtin.SystemActorAddr
var BurntFundsActorAddr = builtin.BurntFundsActorAddr
var CronActorAddr = builtin.CronActorAddr
var SaftAddress = makeAddress("t0122")
var ReserveAddress = makeAddress("t090")
var RootVerifierAddress = makeAddress("t080")

var (
ExpectedLeadersPerEpoch = builtin.ExpectedLeadersPerEpoch
)

const (
Expand All @@ -60,10 +47,6 @@ type ExtendedSectorInfo = proof.ExtendedSectorInfo
type PoStProof = proof.PoStProof
type FilterEstimate = smoothingtypes.FilterEstimate

func QAPowerForWeight(size abi.SectorSize, duration abi.ChainEpoch, dealWeight, verifiedWeight abi.DealWeight) abi.StoragePower {
return minertypes.QAPowerForWeight(size, duration, dealWeight, verifiedWeight)
}

func ActorNameByCode(c cid.Cid) string {
if name, version, ok := actors.GetActorMetaByCode(c); ok {
return fmt.Sprintf("fil/%d/%s", version, name)
Expand Down Expand Up @@ -97,191 +80,6 @@ func ActorNameByCode(c cid.Cid) string {
}
}

func IsBuiltinActor(c cid.Cid) bool {
_, _, ok := actors.GetActorMetaByCode(c)
if ok {
return true
}

if builtin0.IsBuiltinActor(c) {
return true
}

if builtin2.IsBuiltinActor(c) {
return true
}

if builtin3.IsBuiltinActor(c) {
return true
}

if builtin4.IsBuiltinActor(c) {
return true
}

if builtin5.IsBuiltinActor(c) {
return true
}

if builtin6.IsBuiltinActor(c) {
return true
}

if builtin7.IsBuiltinActor(c) {
return true
}

return false
}

func IsAccountActor(c cid.Cid) bool {
name, _, ok := actors.GetActorMetaByCode(c)
if ok {
return name == "account"
}

if c == builtin0.AccountActorCodeID {
return true
}

if c == builtin2.AccountActorCodeID {
return true
}

if c == builtin3.AccountActorCodeID {
return true
}

if c == builtin4.AccountActorCodeID {
return true
}

if c == builtin5.AccountActorCodeID {
return true
}

if c == builtin6.AccountActorCodeID {
return true
}

if c == builtin7.AccountActorCodeID {
return true
}

return false
}

func IsStorageMinerActor(c cid.Cid) bool {
name, _, ok := actors.GetActorMetaByCode(c)
if ok {
return name == actors.MinerKey
}

if c == builtin0.StorageMinerActorCodeID {
return true
}

if c == builtin2.StorageMinerActorCodeID {
return true
}

if c == builtin3.StorageMinerActorCodeID {
return true
}

if c == builtin4.StorageMinerActorCodeID {
return true
}

if c == builtin5.StorageMinerActorCodeID {
return true
}

if c == builtin6.StorageMinerActorCodeID {
return true
}

if c == builtin7.StorageMinerActorCodeID {
return true
}

return false
}

func IsMultisigActor(c cid.Cid) bool {
name, _, ok := actors.GetActorMetaByCode(c)
if ok {
return name == actors.MultisigKey
}

if c == builtin0.MultisigActorCodeID {
return true
}

if c == builtin2.MultisigActorCodeID {
return true
}

if c == builtin3.MultisigActorCodeID {
return true
}

if c == builtin4.MultisigActorCodeID {
return true
}

if c == builtin5.MultisigActorCodeID {
return true
}

if c == builtin6.MultisigActorCodeID {
return true
}

if c == builtin7.MultisigActorCodeID {
return true
}

return false
}

func IsPaymentChannelActor(c cid.Cid) bool {
name, _, ok := actors.GetActorMetaByCode(c)
if ok {
return name == "paymentchannel"
}

if c == builtin0.PaymentChannelActorCodeID {
return true
}

if c == builtin2.PaymentChannelActorCodeID {
return true
}

if c == builtin3.PaymentChannelActorCodeID {
return true
}

if c == builtin4.PaymentChannelActorCodeID {
return true
}

if c == builtin5.PaymentChannelActorCodeID {
return true
}

if c == builtin6.PaymentChannelActorCodeID {
return true
}

if c == builtin7.PaymentChannelActorCodeID {
return true
}

return false
}

func makeAddress(addr string) address.Address {
ret, err := address.NewFromString(addr)
if err != nil {
Expand Down
96 changes: 0 additions & 96 deletions chain/actors/builtin/builtin.go.template
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,14 @@ import (
{{end}}
{{end}}

"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/proof"
"github.com/filecoin-project/go-state-types/builtin"

"github.com/filecoin-project/lotus/chain/actors"

minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner"
smoothingtypes "github.com/filecoin-project/go-state-types/builtin/v8/util/smoothing"
)

var SystemActorAddr = builtin.SystemActorAddr
var BurntFundsActorAddr = builtin.BurntFundsActorAddr
var CronActorAddr = builtin.CronActorAddr
var SaftAddress = makeAddress("t0122")
var ReserveAddress = makeAddress("t090")
var RootVerifierAddress = makeAddress("t080")

var (
ExpectedLeadersPerEpoch = builtin.ExpectedLeadersPerEpoch
)

const (
EpochDurationSeconds = builtin.EpochDurationSeconds
Expand All @@ -52,10 +40,6 @@ type ExtendedSectorInfo = proof.ExtendedSectorInfo
type PoStProof = proof.PoStProof
type FilterEstimate = smoothingtypes.FilterEstimate

func QAPowerForWeight(size abi.SectorSize, duration abi.ChainEpoch, dealWeight, verifiedWeight abi.DealWeight) abi.StoragePower {
return minertypes.QAPowerForWeight(size, duration, dealWeight, verifiedWeight)
}

func ActorNameByCode(c cid.Cid) string {
if name, version, ok := actors.GetActorMetaByCode(c); ok {
return fmt.Sprintf("fil/%d/%s", version, name)
Expand All @@ -73,86 +57,6 @@ func ActorNameByCode(c cid.Cid) string {
}
}

func IsBuiltinActor(c cid.Cid) bool {
_, _, ok := actors.GetActorMetaByCode(c)
if ok {
return true
}

{{range .versions}}
{{if (le . 7)}}
if builtin{{.}}.IsBuiltinActor(c) {
return true
}
{{end}}
{{end}}
return false
}

func IsAccountActor(c cid.Cid) bool {
name, _, ok := actors.GetActorMetaByCode(c)
if ok {
return name == "account"
}

{{range .versions}}
{{if (le . 7)}}
if c == builtin{{.}}.AccountActorCodeID {
return true
}
{{end}}
{{end}}
return false
}

func IsStorageMinerActor(c cid.Cid) bool {
name, _, ok := actors.GetActorMetaByCode(c)
if ok {
return name == actors.MinerKey
}

{{range .versions}}
{{if (le . 7)}}
if c == builtin{{.}}.StorageMinerActorCodeID {
return true
}
{{end}}
{{end}}
return false
}

func IsMultisigActor(c cid.Cid) bool {
name, _, ok := actors.GetActorMetaByCode(c)
if ok {
return name == actors.MultisigKey
}

{{range .versions}}
{{if (le . 7)}}
if c == builtin{{.}}.MultisigActorCodeID {
return true
}
{{end}}
{{end}}
return false
}

func IsPaymentChannelActor(c cid.Cid) bool {
name, _, ok := actors.GetActorMetaByCode(c)
if ok {
return name == "paymentchannel"
}

{{range .versions}}
{{if (le . 7)}}
if c == builtin{{.}}.PaymentChannelActorCodeID {
return true
}
{{end}}
{{end}}
return false
}

func makeAddress(addr string) address.Address {
ret, err := address.NewFromString(addr)
if err != nil {
Expand Down
25 changes: 15 additions & 10 deletions chain/actors/builtin/market/state.go.template
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import (

"github.com/filecoin-project/lotus/chain/actors/adt"

{{if (ge .v 9)}}
verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg"
{{end}}

{{if (le .v 7)}}
market{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/market"
adt{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/util/adt"
Expand Down Expand Up @@ -139,16 +143,17 @@ func (s *dealStates{{.v}}) array() adt.Array {
}

func fromV{{.v}}DealState(v{{.v}} market{{.v}}.DealState) DealState {
{{if (le .v 8)}}
return DealState{
SectorStartEpoch: v{{.v}}.SectorStartEpoch,
LastUpdatedEpoch: v{{.v}}.LastUpdatedEpoch,
SlashEpoch: v{{.v}}.SlashEpoch,
VerifiedClaim: 0,
}
{{else}}
return (DealState)(v{{.v}})
{{end}}
ret := DealState{
SectorStartEpoch: v{{.v}}.SectorStartEpoch,
LastUpdatedEpoch: v{{.v}}.LastUpdatedEpoch,
SlashEpoch: v{{.v}}.SlashEpoch,
VerifiedClaim: 0,
}
{{if (ge .v 9)}}
ret.VerifiedClaim = verifregtypes.AllocationId(v{{.v}}.VerifiedClaim)
{{end}}

return ret
}

type dealProposals{{.v}} struct {
Expand Down
Loading

0 comments on commit fe11b3f

Please sign in to comment.