From e61b9b2a65031092446971e1446cb59a55aeb873 Mon Sep 17 00:00:00 2001 From: frrist Date: Wed, 16 Nov 2022 14:32:59 -0800 Subject: [PATCH 1/3] refactor: add inspection methods to actor gen interface - adds the following methods to all generated actor interfaces: - Code() cid.Cid - ActorKey() string - ActorVersion() actorstypes.Version - AllCodes() []cid.Cid --- chain/actors/builtin/account/account.go | 19 +++++++++++++++ .../actors/builtin/account/actor.go.template | 12 ++++++++++ .../actors/builtin/account/state.go.template | 21 +++++++++++++++++ chain/actors/builtin/account/v0.go | 21 +++++++++++++++++ chain/actors/builtin/account/v2.go | 21 +++++++++++++++++ chain/actors/builtin/account/v3.go | 21 +++++++++++++++++ chain/actors/builtin/account/v4.go | 21 +++++++++++++++++ chain/actors/builtin/account/v5.go | 21 +++++++++++++++++ chain/actors/builtin/account/v6.go | 21 +++++++++++++++++ chain/actors/builtin/account/v7.go | 21 +++++++++++++++++ chain/actors/builtin/account/v8.go | 21 +++++++++++++++++ chain/actors/builtin/account/v9.go | 21 +++++++++++++++++ chain/actors/builtin/cron/actor.go.template | 12 ++++++++++ chain/actors/builtin/cron/cron.go | 19 +++++++++++++++ chain/actors/builtin/cron/state.go.template | 22 +++++++++++++++++- chain/actors/builtin/cron/v0.go | 21 +++++++++++++++++ chain/actors/builtin/cron/v2.go | 21 +++++++++++++++++ chain/actors/builtin/cron/v3.go | 21 +++++++++++++++++ chain/actors/builtin/cron/v4.go | 21 +++++++++++++++++ chain/actors/builtin/cron/v5.go | 21 +++++++++++++++++ chain/actors/builtin/cron/v6.go | 21 +++++++++++++++++ chain/actors/builtin/cron/v7.go | 21 +++++++++++++++++ chain/actors/builtin/cron/v8.go | 21 +++++++++++++++++ chain/actors/builtin/cron/v9.go | 21 +++++++++++++++++ .../actors/builtin/datacap/actor.go.template | 13 +++++++++++ chain/actors/builtin/datacap/datacap.go | 11 +++++++++ .../actors/builtin/datacap/state.go.template | 19 +++++++++++++++ chain/actors/builtin/datacap/v9.go | 20 ++++++++++++++++ chain/actors/builtin/init/actor.go.template | 11 +++++++++ chain/actors/builtin/init/init.go | 18 +++++++++++++++ chain/actors/builtin/init/state.go.template | 23 ++++++++++++++++++- chain/actors/builtin/init/v0.go | 20 ++++++++++++++++ chain/actors/builtin/init/v2.go | 20 ++++++++++++++++ chain/actors/builtin/init/v3.go | 20 ++++++++++++++++ chain/actors/builtin/init/v4.go | 20 ++++++++++++++++ chain/actors/builtin/init/v5.go | 20 ++++++++++++++++ chain/actors/builtin/init/v6.go | 20 ++++++++++++++++ chain/actors/builtin/init/v7.go | 20 ++++++++++++++++ chain/actors/builtin/init/v8.go | 20 ++++++++++++++++ chain/actors/builtin/init/v9.go | 20 ++++++++++++++++ chain/actors/builtin/market/actor.go.template | 13 +++++++++++ chain/actors/builtin/market/market.go | 20 ++++++++++++++++ chain/actors/builtin/market/state.go.template | 21 +++++++++++++++++ chain/actors/builtin/market/v0.go | 20 ++++++++++++++++ chain/actors/builtin/market/v2.go | 20 ++++++++++++++++ chain/actors/builtin/market/v3.go | 20 ++++++++++++++++ chain/actors/builtin/market/v4.go | 20 ++++++++++++++++ chain/actors/builtin/market/v5.go | 20 ++++++++++++++++ chain/actors/builtin/market/v6.go | 20 ++++++++++++++++ chain/actors/builtin/market/v7.go | 20 ++++++++++++++++ chain/actors/builtin/market/v8.go | 20 ++++++++++++++++ chain/actors/builtin/market/v9.go | 20 ++++++++++++++++ chain/actors/builtin/miner/actor.go.template | 12 ++++++++++ chain/actors/builtin/miner/miner.go | 19 +++++++++++++++ chain/actors/builtin/miner/state.go.template | 20 ++++++++++++++++ chain/actors/builtin/miner/v0.go | 20 ++++++++++++++++ chain/actors/builtin/miner/v2.go | 20 ++++++++++++++++ chain/actors/builtin/miner/v3.go | 20 ++++++++++++++++ chain/actors/builtin/miner/v4.go | 20 ++++++++++++++++ chain/actors/builtin/miner/v5.go | 20 ++++++++++++++++ chain/actors/builtin/miner/v6.go | 20 ++++++++++++++++ chain/actors/builtin/miner/v7.go | 20 ++++++++++++++++ chain/actors/builtin/miner/v8.go | 20 ++++++++++++++++ chain/actors/builtin/miner/v9.go | 20 ++++++++++++++++ .../actors/builtin/multisig/actor.go.template | 12 ++++++++++ chain/actors/builtin/multisig/multisig.go | 19 +++++++++++++++ .../actors/builtin/multisig/state.go.template | 20 ++++++++++++++++ chain/actors/builtin/multisig/v0.go | 20 ++++++++++++++++ chain/actors/builtin/multisig/v2.go | 20 ++++++++++++++++ chain/actors/builtin/multisig/v3.go | 20 ++++++++++++++++ chain/actors/builtin/multisig/v4.go | 20 ++++++++++++++++ chain/actors/builtin/multisig/v5.go | 20 ++++++++++++++++ chain/actors/builtin/multisig/v6.go | 20 ++++++++++++++++ chain/actors/builtin/multisig/v7.go | 20 ++++++++++++++++ chain/actors/builtin/multisig/v8.go | 20 ++++++++++++++++ chain/actors/builtin/multisig/v9.go | 20 ++++++++++++++++ chain/actors/builtin/paych/actor.go.template | 16 ++++++++++++- chain/actors/builtin/paych/paych.go | 20 ++++++++++++++++ chain/actors/builtin/paych/state.go.template | 20 ++++++++++++++++ chain/actors/builtin/paych/v0.go | 21 +++++++++++++++++ chain/actors/builtin/paych/v2.go | 21 +++++++++++++++++ chain/actors/builtin/paych/v3.go | 21 +++++++++++++++++ chain/actors/builtin/paych/v4.go | 21 +++++++++++++++++ chain/actors/builtin/paych/v5.go | 21 +++++++++++++++++ chain/actors/builtin/paych/v6.go | 21 +++++++++++++++++ chain/actors/builtin/paych/v7.go | 21 +++++++++++++++++ chain/actors/builtin/paych/v8.go | 21 +++++++++++++++++ chain/actors/builtin/paych/v9.go | 21 +++++++++++++++++ chain/actors/builtin/power/actor.go.template | 12 ++++++++++ chain/actors/builtin/power/power.go | 19 +++++++++++++++ chain/actors/builtin/power/state.go.template | 20 ++++++++++++++++ chain/actors/builtin/power/v0.go | 20 ++++++++++++++++ chain/actors/builtin/power/v2.go | 20 ++++++++++++++++ chain/actors/builtin/power/v3.go | 20 ++++++++++++++++ chain/actors/builtin/power/v4.go | 20 ++++++++++++++++ chain/actors/builtin/power/v5.go | 20 ++++++++++++++++ chain/actors/builtin/power/v6.go | 20 ++++++++++++++++ chain/actors/builtin/power/v7.go | 20 ++++++++++++++++ chain/actors/builtin/power/v8.go | 20 ++++++++++++++++ chain/actors/builtin/power/v9.go | 20 ++++++++++++++++ chain/actors/builtin/reward/actor.go.template | 12 ++++++++++ chain/actors/builtin/reward/reward.go | 19 +++++++++++++++ chain/actors/builtin/reward/state.go.template | 20 ++++++++++++++++ chain/actors/builtin/reward/v0.go | 21 +++++++++++++++++ chain/actors/builtin/reward/v2.go | 21 +++++++++++++++++ chain/actors/builtin/reward/v3.go | 21 +++++++++++++++++ chain/actors/builtin/reward/v4.go | 21 +++++++++++++++++ chain/actors/builtin/reward/v5.go | 21 +++++++++++++++++ chain/actors/builtin/reward/v6.go | 21 +++++++++++++++++ chain/actors/builtin/reward/v7.go | 21 +++++++++++++++++ chain/actors/builtin/reward/v8.go | 21 +++++++++++++++++ chain/actors/builtin/reward/v9.go | 21 +++++++++++++++++ chain/actors/builtin/system/actor.go.template | 12 ++++++++++ chain/actors/builtin/system/state.go.template | 23 ++++++++++++++++++- chain/actors/builtin/system/system.go | 18 +++++++++++++++ chain/actors/builtin/system/v0.go | 21 +++++++++++++++++ chain/actors/builtin/system/v2.go | 21 +++++++++++++++++ chain/actors/builtin/system/v3.go | 21 +++++++++++++++++ chain/actors/builtin/system/v4.go | 21 +++++++++++++++++ chain/actors/builtin/system/v5.go | 21 +++++++++++++++++ chain/actors/builtin/system/v6.go | 21 +++++++++++++++++ chain/actors/builtin/system/v7.go | 21 +++++++++++++++++ chain/actors/builtin/system/v8.go | 21 +++++++++++++++++ chain/actors/builtin/system/v9.go | 21 +++++++++++++++++ .../actors/builtin/verifreg/actor.go.template | 12 ++++++++++ .../actors/builtin/verifreg/state.go.template | 19 +++++++++++++++ chain/actors/builtin/verifreg/v0.go | 20 ++++++++++++++++ chain/actors/builtin/verifreg/v2.go | 20 ++++++++++++++++ chain/actors/builtin/verifreg/v3.go | 20 ++++++++++++++++ chain/actors/builtin/verifreg/v4.go | 20 ++++++++++++++++ chain/actors/builtin/verifreg/v5.go | 20 ++++++++++++++++ chain/actors/builtin/verifreg/v6.go | 20 ++++++++++++++++ chain/actors/builtin/verifreg/v7.go | 20 ++++++++++++++++ chain/actors/builtin/verifreg/v8.go | 20 ++++++++++++++++ chain/actors/builtin/verifreg/v9.go | 20 ++++++++++++++++ chain/actors/builtin/verifreg/verifreg.go | 19 +++++++++++++++ lib/consensus/raft/config.go | 4 ++-- 137 files changed, 2660 insertions(+), 6 deletions(-) diff --git a/chain/actors/builtin/account/account.go b/chain/actors/builtin/account/account.go index f8c65a9b9..789f934d6 100644 --- a/chain/actors/builtin/account/account.go +++ b/chain/actors/builtin/account/account.go @@ -1,6 +1,7 @@ package account import ( + "github.com/ipfs/go-cid" "golang.org/x/xerrors" "github.com/filecoin-project/go-address" @@ -104,6 +105,24 @@ func MakeState(store adt.Store, av actorstypes.Version, addr address.Address) (S type State interface { cbor.Marshaler + Code() cid.Cid + ActorKey() string + ActorVersion() actorstypes.Version + PubkeyAddress() (address.Address, error) GetState() interface{} } + +func AllCodes() []cid.Cid { + return []cid.Cid{ + (&state0{}).Code(), + (&state2{}).Code(), + (&state3{}).Code(), + (&state4{}).Code(), + (&state5{}).Code(), + (&state6{}).Code(), + (&state7{}).Code(), + (&state8{}).Code(), + (&state9{}).Code(), + } +} diff --git a/chain/actors/builtin/account/actor.go.template b/chain/actors/builtin/account/actor.go.template index 07b4cc94b..ef6e7ac3d 100644 --- a/chain/actors/builtin/account/actor.go.template +++ b/chain/actors/builtin/account/actor.go.template @@ -1,6 +1,7 @@ package account import ( + "github.com/ipfs/go-cid" actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/lotus/chain/actors" "golang.org/x/xerrors" @@ -62,6 +63,17 @@ func MakeState(store adt.Store, av actorstypes.Version, addr address.Address) (S type State interface { cbor.Marshaler + Code() cid.Cid + ActorKey() string + ActorVersion() actorstypes.Version + PubkeyAddress() (address.Address, error) GetState() interface{} } + +func AllCodes() []cid.Cid { + return []cid.Cid{ {{range .versions}} + (&state{{.}}{}).Code(), + {{- end}} + } +} diff --git a/chain/actors/builtin/account/state.go.template b/chain/actors/builtin/account/state.go.template index 93e7dc0db..9b623519d 100644 --- a/chain/actors/builtin/account/state.go.template +++ b/chain/actors/builtin/account/state.go.template @@ -1,10 +1,14 @@ package account import ( + "fmt" + actorstypes "github.com/filecoin-project/go-state-types/actors" + "github.com/filecoin-project/go-address" "github.com/ipfs/go-cid" "github.com/filecoin-project/lotus/chain/actors/adt" + "github.com/filecoin-project/lotus/chain/actors" {{if (le .v 7)}} account{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/account" @@ -41,4 +45,21 @@ func (s *state{{.v}}) PubkeyAddress() (address.Address, error) { func (s *state{{.v}}) GetState() interface{} { return &s.State +} + +func (s *state{{.v}}) ActorKey() string { + return actors.AccountKey +} + +func (s *state{{.v}}) ActorVersion() actorstypes.Version { + return actorstypes.Version{{.v}} +} + +func (s *state{{.v}}) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code } \ No newline at end of file diff --git a/chain/actors/builtin/account/v0.go b/chain/actors/builtin/account/v0.go index 314bd4b29..f6af2c79c 100644 --- a/chain/actors/builtin/account/v0.go +++ b/chain/actors/builtin/account/v0.go @@ -1,11 +1,15 @@ package account import ( + "fmt" + "github.com/ipfs/go-cid" "github.com/filecoin-project/go-address" + actorstypes "github.com/filecoin-project/go-state-types/actors" account0 "github.com/filecoin-project/specs-actors/actors/builtin/account" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -38,3 +42,20 @@ func (s *state0) PubkeyAddress() (address.Address, error) { func (s *state0) GetState() interface{} { return &s.State } + +func (s *state0) ActorKey() string { + return actors.AccountKey +} + +func (s *state0) ActorVersion() actorstypes.Version { + return actorstypes.Version0 +} + +func (s *state0) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/account/v2.go b/chain/actors/builtin/account/v2.go index 605065424..5e2297b4a 100644 --- a/chain/actors/builtin/account/v2.go +++ b/chain/actors/builtin/account/v2.go @@ -1,11 +1,15 @@ package account import ( + "fmt" + "github.com/ipfs/go-cid" "github.com/filecoin-project/go-address" + actorstypes "github.com/filecoin-project/go-state-types/actors" account2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/account" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -38,3 +42,20 @@ func (s *state2) PubkeyAddress() (address.Address, error) { func (s *state2) GetState() interface{} { return &s.State } + +func (s *state2) ActorKey() string { + return actors.AccountKey +} + +func (s *state2) ActorVersion() actorstypes.Version { + return actorstypes.Version2 +} + +func (s *state2) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/account/v3.go b/chain/actors/builtin/account/v3.go index d070476ea..4e142bcf7 100644 --- a/chain/actors/builtin/account/v3.go +++ b/chain/actors/builtin/account/v3.go @@ -1,11 +1,15 @@ package account import ( + "fmt" + "github.com/ipfs/go-cid" "github.com/filecoin-project/go-address" + actorstypes "github.com/filecoin-project/go-state-types/actors" account3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/account" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -38,3 +42,20 @@ func (s *state3) PubkeyAddress() (address.Address, error) { func (s *state3) GetState() interface{} { return &s.State } + +func (s *state3) ActorKey() string { + return actors.AccountKey +} + +func (s *state3) ActorVersion() actorstypes.Version { + return actorstypes.Version3 +} + +func (s *state3) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/account/v4.go b/chain/actors/builtin/account/v4.go index f4d9f7a06..7b1e7f0dd 100644 --- a/chain/actors/builtin/account/v4.go +++ b/chain/actors/builtin/account/v4.go @@ -1,11 +1,15 @@ package account import ( + "fmt" + "github.com/ipfs/go-cid" "github.com/filecoin-project/go-address" + actorstypes "github.com/filecoin-project/go-state-types/actors" account4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/account" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -38,3 +42,20 @@ func (s *state4) PubkeyAddress() (address.Address, error) { func (s *state4) GetState() interface{} { return &s.State } + +func (s *state4) ActorKey() string { + return actors.AccountKey +} + +func (s *state4) ActorVersion() actorstypes.Version { + return actorstypes.Version4 +} + +func (s *state4) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/account/v5.go b/chain/actors/builtin/account/v5.go index 5e01ce152..ad8bed522 100644 --- a/chain/actors/builtin/account/v5.go +++ b/chain/actors/builtin/account/v5.go @@ -1,11 +1,15 @@ package account import ( + "fmt" + "github.com/ipfs/go-cid" "github.com/filecoin-project/go-address" + actorstypes "github.com/filecoin-project/go-state-types/actors" account5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/account" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -38,3 +42,20 @@ func (s *state5) PubkeyAddress() (address.Address, error) { func (s *state5) GetState() interface{} { return &s.State } + +func (s *state5) ActorKey() string { + return actors.AccountKey +} + +func (s *state5) ActorVersion() actorstypes.Version { + return actorstypes.Version5 +} + +func (s *state5) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/account/v6.go b/chain/actors/builtin/account/v6.go index 85135dcda..74c959c5f 100644 --- a/chain/actors/builtin/account/v6.go +++ b/chain/actors/builtin/account/v6.go @@ -1,11 +1,15 @@ package account import ( + "fmt" + "github.com/ipfs/go-cid" "github.com/filecoin-project/go-address" + actorstypes "github.com/filecoin-project/go-state-types/actors" account6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/account" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -38,3 +42,20 @@ func (s *state6) PubkeyAddress() (address.Address, error) { func (s *state6) GetState() interface{} { return &s.State } + +func (s *state6) ActorKey() string { + return actors.AccountKey +} + +func (s *state6) ActorVersion() actorstypes.Version { + return actorstypes.Version6 +} + +func (s *state6) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/account/v7.go b/chain/actors/builtin/account/v7.go index 4ae979b82..24d259f33 100644 --- a/chain/actors/builtin/account/v7.go +++ b/chain/actors/builtin/account/v7.go @@ -1,11 +1,15 @@ package account import ( + "fmt" + "github.com/ipfs/go-cid" "github.com/filecoin-project/go-address" + actorstypes "github.com/filecoin-project/go-state-types/actors" account7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/account" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -38,3 +42,20 @@ func (s *state7) PubkeyAddress() (address.Address, error) { func (s *state7) GetState() interface{} { return &s.State } + +func (s *state7) ActorKey() string { + return actors.AccountKey +} + +func (s *state7) ActorVersion() actorstypes.Version { + return actorstypes.Version7 +} + +func (s *state7) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/account/v8.go b/chain/actors/builtin/account/v8.go index 211deea33..2a4a74ca4 100644 --- a/chain/actors/builtin/account/v8.go +++ b/chain/actors/builtin/account/v8.go @@ -1,11 +1,15 @@ package account import ( + "fmt" + "github.com/ipfs/go-cid" "github.com/filecoin-project/go-address" + actorstypes "github.com/filecoin-project/go-state-types/actors" account8 "github.com/filecoin-project/go-state-types/builtin/v8/account" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -38,3 +42,20 @@ func (s *state8) PubkeyAddress() (address.Address, error) { func (s *state8) GetState() interface{} { return &s.State } + +func (s *state8) ActorKey() string { + return actors.AccountKey +} + +func (s *state8) ActorVersion() actorstypes.Version { + return actorstypes.Version8 +} + +func (s *state8) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/account/v9.go b/chain/actors/builtin/account/v9.go index 7e172b33c..97bcd43d7 100644 --- a/chain/actors/builtin/account/v9.go +++ b/chain/actors/builtin/account/v9.go @@ -1,11 +1,15 @@ package account import ( + "fmt" + "github.com/ipfs/go-cid" "github.com/filecoin-project/go-address" + actorstypes "github.com/filecoin-project/go-state-types/actors" account9 "github.com/filecoin-project/go-state-types/builtin/v9/account" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -38,3 +42,20 @@ func (s *state9) PubkeyAddress() (address.Address, error) { func (s *state9) GetState() interface{} { return &s.State } + +func (s *state9) ActorKey() string { + return actors.AccountKey +} + +func (s *state9) ActorVersion() actorstypes.Version { + return actorstypes.Version9 +} + +func (s *state9) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/cron/actor.go.template b/chain/actors/builtin/cron/actor.go.template index 67c781fb2..3abb33e63 100644 --- a/chain/actors/builtin/cron/actor.go.template +++ b/chain/actors/builtin/cron/actor.go.template @@ -1,6 +1,7 @@ package cron import ( + "github.com/ipfs/go-cid" actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" @@ -60,5 +61,16 @@ var ( type State interface { + Code() cid.Cid + ActorKey() string + ActorVersion() actorstypes.Version + GetState() interface{} } + +func AllCodes() []cid.Cid { + return []cid.Cid{ {{range .versions}} + (&state{{.}}{}).Code(), + {{- end}} + } +} diff --git a/chain/actors/builtin/cron/cron.go b/chain/actors/builtin/cron/cron.go index 29f795476..afabb7d84 100644 --- a/chain/actors/builtin/cron/cron.go +++ b/chain/actors/builtin/cron/cron.go @@ -1,6 +1,7 @@ package cron import ( + "github.com/ipfs/go-cid" "golang.org/x/xerrors" actorstypes "github.com/filecoin-project/go-state-types/actors" @@ -103,5 +104,23 @@ var ( ) type State interface { + Code() cid.Cid + ActorKey() string + ActorVersion() actorstypes.Version + GetState() interface{} } + +func AllCodes() []cid.Cid { + return []cid.Cid{ + (&state0{}).Code(), + (&state2{}).Code(), + (&state3{}).Code(), + (&state4{}).Code(), + (&state5{}).Code(), + (&state6{}).Code(), + (&state7{}).Code(), + (&state8{}).Code(), + (&state9{}).Code(), + } +} diff --git a/chain/actors/builtin/cron/state.go.template b/chain/actors/builtin/cron/state.go.template index 13cdc46c9..24739f162 100644 --- a/chain/actors/builtin/cron/state.go.template +++ b/chain/actors/builtin/cron/state.go.template @@ -1,9 +1,12 @@ package cron import ( + "fmt" "github.com/ipfs/go-cid" "github.com/filecoin-project/lotus/chain/actors/adt" + "github.com/filecoin-project/lotus/chain/actors" + actorstypes "github.com/filecoin-project/go-state-types/actors" {{if (le .v 7)}} cron{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/cron" @@ -36,4 +39,21 @@ type state{{.v}} struct { func (s *state{{.v}}) GetState() interface{} { return &s.State -} \ No newline at end of file +} + +func (s *state{{.v}}) ActorKey() string { + return actors.CronKey +} + +func (s *state{{.v}}) ActorVersion() actorstypes.Version { + return actorstypes.Version{{.v}} +} + +func (s *state{{.v}}) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/cron/v0.go b/chain/actors/builtin/cron/v0.go index baa81aac3..ef5f6d93e 100644 --- a/chain/actors/builtin/cron/v0.go +++ b/chain/actors/builtin/cron/v0.go @@ -1,10 +1,14 @@ package cron import ( + "fmt" + "github.com/ipfs/go-cid" + actorstypes "github.com/filecoin-project/go-state-types/actors" cron0 "github.com/filecoin-project/specs-actors/actors/builtin/cron" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -33,3 +37,20 @@ type state0 struct { func (s *state0) GetState() interface{} { return &s.State } + +func (s *state0) ActorKey() string { + return actors.CronKey +} + +func (s *state0) ActorVersion() actorstypes.Version { + return actorstypes.Version0 +} + +func (s *state0) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/cron/v2.go b/chain/actors/builtin/cron/v2.go index d6ee35935..fc45be0de 100644 --- a/chain/actors/builtin/cron/v2.go +++ b/chain/actors/builtin/cron/v2.go @@ -1,10 +1,14 @@ package cron import ( + "fmt" + "github.com/ipfs/go-cid" + actorstypes "github.com/filecoin-project/go-state-types/actors" cron2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/cron" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -33,3 +37,20 @@ type state2 struct { func (s *state2) GetState() interface{} { return &s.State } + +func (s *state2) ActorKey() string { + return actors.CronKey +} + +func (s *state2) ActorVersion() actorstypes.Version { + return actorstypes.Version2 +} + +func (s *state2) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/cron/v3.go b/chain/actors/builtin/cron/v3.go index 356d385cd..6f8e66a3b 100644 --- a/chain/actors/builtin/cron/v3.go +++ b/chain/actors/builtin/cron/v3.go @@ -1,10 +1,14 @@ package cron import ( + "fmt" + "github.com/ipfs/go-cid" + actorstypes "github.com/filecoin-project/go-state-types/actors" cron3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/cron" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -33,3 +37,20 @@ type state3 struct { func (s *state3) GetState() interface{} { return &s.State } + +func (s *state3) ActorKey() string { + return actors.CronKey +} + +func (s *state3) ActorVersion() actorstypes.Version { + return actorstypes.Version3 +} + +func (s *state3) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/cron/v4.go b/chain/actors/builtin/cron/v4.go index 3db3c95aa..2539f2b1c 100644 --- a/chain/actors/builtin/cron/v4.go +++ b/chain/actors/builtin/cron/v4.go @@ -1,10 +1,14 @@ package cron import ( + "fmt" + "github.com/ipfs/go-cid" + actorstypes "github.com/filecoin-project/go-state-types/actors" cron4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/cron" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -33,3 +37,20 @@ type state4 struct { func (s *state4) GetState() interface{} { return &s.State } + +func (s *state4) ActorKey() string { + return actors.CronKey +} + +func (s *state4) ActorVersion() actorstypes.Version { + return actorstypes.Version4 +} + +func (s *state4) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/cron/v5.go b/chain/actors/builtin/cron/v5.go index 5d99af1fd..8aba47a2b 100644 --- a/chain/actors/builtin/cron/v5.go +++ b/chain/actors/builtin/cron/v5.go @@ -1,10 +1,14 @@ package cron import ( + "fmt" + "github.com/ipfs/go-cid" + actorstypes "github.com/filecoin-project/go-state-types/actors" cron5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/cron" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -33,3 +37,20 @@ type state5 struct { func (s *state5) GetState() interface{} { return &s.State } + +func (s *state5) ActorKey() string { + return actors.CronKey +} + +func (s *state5) ActorVersion() actorstypes.Version { + return actorstypes.Version5 +} + +func (s *state5) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/cron/v6.go b/chain/actors/builtin/cron/v6.go index c86cd6c42..f607a409f 100644 --- a/chain/actors/builtin/cron/v6.go +++ b/chain/actors/builtin/cron/v6.go @@ -1,10 +1,14 @@ package cron import ( + "fmt" + "github.com/ipfs/go-cid" + actorstypes "github.com/filecoin-project/go-state-types/actors" cron6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/cron" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -33,3 +37,20 @@ type state6 struct { func (s *state6) GetState() interface{} { return &s.State } + +func (s *state6) ActorKey() string { + return actors.CronKey +} + +func (s *state6) ActorVersion() actorstypes.Version { + return actorstypes.Version6 +} + +func (s *state6) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/cron/v7.go b/chain/actors/builtin/cron/v7.go index db9f8f9e2..ef962fd41 100644 --- a/chain/actors/builtin/cron/v7.go +++ b/chain/actors/builtin/cron/v7.go @@ -1,10 +1,14 @@ package cron import ( + "fmt" + "github.com/ipfs/go-cid" + actorstypes "github.com/filecoin-project/go-state-types/actors" cron7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/cron" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -33,3 +37,20 @@ type state7 struct { func (s *state7) GetState() interface{} { return &s.State } + +func (s *state7) ActorKey() string { + return actors.CronKey +} + +func (s *state7) ActorVersion() actorstypes.Version { + return actorstypes.Version7 +} + +func (s *state7) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/cron/v8.go b/chain/actors/builtin/cron/v8.go index 00567acf9..377cba060 100644 --- a/chain/actors/builtin/cron/v8.go +++ b/chain/actors/builtin/cron/v8.go @@ -1,10 +1,14 @@ package cron import ( + "fmt" + "github.com/ipfs/go-cid" + actorstypes "github.com/filecoin-project/go-state-types/actors" cron8 "github.com/filecoin-project/go-state-types/builtin/v8/cron" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -33,3 +37,20 @@ type state8 struct { func (s *state8) GetState() interface{} { return &s.State } + +func (s *state8) ActorKey() string { + return actors.CronKey +} + +func (s *state8) ActorVersion() actorstypes.Version { + return actorstypes.Version8 +} + +func (s *state8) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/cron/v9.go b/chain/actors/builtin/cron/v9.go index 312a33b68..b2e1d1265 100644 --- a/chain/actors/builtin/cron/v9.go +++ b/chain/actors/builtin/cron/v9.go @@ -1,10 +1,14 @@ package cron import ( + "fmt" + "github.com/ipfs/go-cid" + actorstypes "github.com/filecoin-project/go-state-types/actors" cron9 "github.com/filecoin-project/go-state-types/builtin/v9/cron" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -33,3 +37,20 @@ type state9 struct { func (s *state9) GetState() interface{} { return &s.State } + +func (s *state9) ActorKey() string { + return actors.CronKey +} + +func (s *state9) ActorVersion() actorstypes.Version { + return actorstypes.Version9 +} + +func (s *state9) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/datacap/actor.go.template b/chain/actors/builtin/datacap/actor.go.template index 9a3f2bdb8..bd57f17a0 100644 --- a/chain/actors/builtin/datacap/actor.go.template +++ b/chain/actors/builtin/datacap/actor.go.template @@ -3,6 +3,8 @@ package datacap import ( "golang.org/x/xerrors" + "github.com/ipfs/go-cid" + "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" actorstypes "github.com/filecoin-project/go-state-types/actors" @@ -50,8 +52,19 @@ func MakeState(store adt.Store, av actorstypes.Version, governor address.Address type State interface { cbor.Marshaler + Code() cid.Cid + ActorKey() string + ActorVersion() actorstypes.Version + ForEachClient(func(addr address.Address, dcap abi.StoragePower) error) error VerifiedClientDataCap(address.Address) (bool, abi.StoragePower, error) Governor() (address.Address, error) GetState() interface{} } + +func AllCodes() []cid.Cid { + return []cid.Cid{ {{range .versions}} + (&state{{.}}{}).Code(), + {{- end}} + } +} diff --git a/chain/actors/builtin/datacap/datacap.go b/chain/actors/builtin/datacap/datacap.go index 3915c01e5..f227181cf 100644 --- a/chain/actors/builtin/datacap/datacap.go +++ b/chain/actors/builtin/datacap/datacap.go @@ -1,6 +1,7 @@ package datacap import ( + "github.com/ipfs/go-cid" "golang.org/x/xerrors" "github.com/filecoin-project/go-address" @@ -51,8 +52,18 @@ func MakeState(store adt.Store, av actorstypes.Version, governor address.Address type State interface { cbor.Marshaler + Code() cid.Cid + ActorKey() string + ActorVersion() actorstypes.Version + ForEachClient(func(addr address.Address, dcap abi.StoragePower) error) error VerifiedClientDataCap(address.Address) (bool, abi.StoragePower, error) Governor() (address.Address, error) GetState() interface{} } + +func AllCodes() []cid.Cid { + return []cid.Cid{ + (&state9{}).Code(), + } +} diff --git a/chain/actors/builtin/datacap/state.go.template b/chain/actors/builtin/datacap/state.go.template index 297f9f79f..dfb6eaad4 100644 --- a/chain/actors/builtin/datacap/state.go.template +++ b/chain/actors/builtin/datacap/state.go.template @@ -1,12 +1,14 @@ package datacap import ( + "fmt" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/ipfs/go-cid" "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" + actorstypes "github.com/filecoin-project/go-state-types/actors" datacap{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}datacap" adt{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}util/adt" @@ -59,3 +61,20 @@ func (s *state{{.v}}) verifiedClients() (adt.Map, error) { func (s *state{{.v}}) VerifiedClientDataCap(addr address.Address) (bool, abi.StoragePower, error) { return getDataCap(s.store, actors.Version{{.v}}, s.verifiedClients, addr) } + +func (s *state{{.v}}) ActorKey() string { + return actors.DatacapKey +} + +func (s *state{{.v}}) ActorVersion() actorstypes.Version { + return actorstypes.Version{{.v}} +} + +func (s *state{{.v}}) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/datacap/v9.go b/chain/actors/builtin/datacap/v9.go index a6e4bbcd6..6dcf04477 100644 --- a/chain/actors/builtin/datacap/v9.go +++ b/chain/actors/builtin/datacap/v9.go @@ -1,10 +1,13 @@ package datacap import ( + "fmt" + "github.com/ipfs/go-cid" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" datacap9 "github.com/filecoin-project/go-state-types/builtin/v9/datacap" adt9 "github.com/filecoin-project/go-state-types/builtin/v9/util/adt" @@ -59,3 +62,20 @@ func (s *state9) verifiedClients() (adt.Map, error) { func (s *state9) VerifiedClientDataCap(addr address.Address) (bool, abi.StoragePower, error) { return getDataCap(s.store, actors.Version9, s.verifiedClients, addr) } + +func (s *state9) ActorKey() string { + return actors.DatacapKey +} + +func (s *state9) ActorVersion() actorstypes.Version { + return actorstypes.Version9 +} + +func (s *state9) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/init/actor.go.template b/chain/actors/builtin/init/actor.go.template index 06a317bfa..453aba963 100644 --- a/chain/actors/builtin/init/actor.go.template +++ b/chain/actors/builtin/init/actor.go.template @@ -67,6 +67,10 @@ func MakeState(store adt.Store, av actorstypes.Version, networkName string) (Sta type State interface { cbor.Marshaler + Code() cid.Cid + ActorKey() string + ActorVersion() actorstypes.Version + ResolveAddress(address address.Address) (address.Address, bool, error) MapAddressToNewID(address address.Address) (address.Address, error) NetworkName() (dtypes.NetworkName, error) @@ -93,3 +97,10 @@ type State interface { AddressMapBitWidth() int AddressMapHashFunction() func(input []byte) []byte } + +func AllCodes() []cid.Cid { + return []cid.Cid{ {{range .versions}} + (&state{{.}}{}).Code(), + {{- end}} + } +} diff --git a/chain/actors/builtin/init/init.go b/chain/actors/builtin/init/init.go index bb44d8369..7248bd870 100644 --- a/chain/actors/builtin/init/init.go +++ b/chain/actors/builtin/init/init.go @@ -110,6 +110,10 @@ func MakeState(store adt.Store, av actorstypes.Version, networkName string) (Sta type State interface { cbor.Marshaler + Code() cid.Cid + ActorKey() string + ActorVersion() actorstypes.Version + ResolveAddress(address address.Address) (address.Address, bool, error) MapAddressToNewID(address address.Address) (address.Address, error) NetworkName() (dtypes.NetworkName, error) @@ -136,3 +140,17 @@ type State interface { AddressMapBitWidth() int AddressMapHashFunction() func(input []byte) []byte } + +func AllCodes() []cid.Cid { + return []cid.Cid{ + (&state0{}).Code(), + (&state2{}).Code(), + (&state3{}).Code(), + (&state4{}).Code(), + (&state5{}).Code(), + (&state6{}).Code(), + (&state7{}).Code(), + (&state8{}).Code(), + (&state9{}).Code(), + } +} diff --git a/chain/actors/builtin/init/state.go.template b/chain/actors/builtin/init/state.go.template index 00ed82b93..c31aef6a0 100644 --- a/chain/actors/builtin/init/state.go.template +++ b/chain/actors/builtin/init/state.go.template @@ -2,13 +2,17 @@ package init import ( "crypto/sha256" + "fmt" + "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/lotus/node/modules/dtypes" {{if (le .v 7)}} @@ -141,4 +145,21 @@ func (s *state{{.v}}) AddressMapHashFunction() func(input []byte) []byte { res := sha256.Sum256(input) return res[:] } -} \ No newline at end of file +} + +func (s *state{{.v}}) ActorKey() string { + return actors.InitKey +} + +func (s *state{{.v}}) ActorVersion() actorstypes.Version { + return actorstypes.Version{{.v}} +} + +func (s *state{{.v}}) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/init/v0.go b/chain/actors/builtin/init/v0.go index cd7b91f8a..61ae3f2db 100644 --- a/chain/actors/builtin/init/v0.go +++ b/chain/actors/builtin/init/v0.go @@ -2,6 +2,7 @@ package init import ( "crypto/sha256" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" @@ -9,9 +10,11 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" init0 "github.com/filecoin-project/specs-actors/actors/builtin/init" adt0 "github.com/filecoin-project/specs-actors/actors/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/node/modules/dtypes" ) @@ -123,3 +126,20 @@ func (s *state0) AddressMapHashFunction() func(input []byte) []byte { return res[:] } } + +func (s *state0) ActorKey() string { + return actors.InitKey +} + +func (s *state0) ActorVersion() actorstypes.Version { + return actorstypes.Version0 +} + +func (s *state0) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/init/v2.go b/chain/actors/builtin/init/v2.go index 91641f6f5..dfbdde6c9 100644 --- a/chain/actors/builtin/init/v2.go +++ b/chain/actors/builtin/init/v2.go @@ -2,6 +2,7 @@ package init import ( "crypto/sha256" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" @@ -9,9 +10,11 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" init2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/init" adt2 "github.com/filecoin-project/specs-actors/v2/actors/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/node/modules/dtypes" ) @@ -123,3 +126,20 @@ func (s *state2) AddressMapHashFunction() func(input []byte) []byte { return res[:] } } + +func (s *state2) ActorKey() string { + return actors.InitKey +} + +func (s *state2) ActorVersion() actorstypes.Version { + return actorstypes.Version2 +} + +func (s *state2) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/init/v3.go b/chain/actors/builtin/init/v3.go index 6e7d81b39..56a5e4afd 100644 --- a/chain/actors/builtin/init/v3.go +++ b/chain/actors/builtin/init/v3.go @@ -2,6 +2,7 @@ package init import ( "crypto/sha256" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" @@ -9,10 +10,12 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin" init3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/init" adt3 "github.com/filecoin-project/specs-actors/v3/actors/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/node/modules/dtypes" ) @@ -124,3 +127,20 @@ func (s *state3) AddressMapHashFunction() func(input []byte) []byte { return res[:] } } + +func (s *state3) ActorKey() string { + return actors.InitKey +} + +func (s *state3) ActorVersion() actorstypes.Version { + return actorstypes.Version3 +} + +func (s *state3) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/init/v4.go b/chain/actors/builtin/init/v4.go index 67c797c2b..b1ecd3188 100644 --- a/chain/actors/builtin/init/v4.go +++ b/chain/actors/builtin/init/v4.go @@ -2,6 +2,7 @@ package init import ( "crypto/sha256" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" @@ -9,10 +10,12 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin" init4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/init" adt4 "github.com/filecoin-project/specs-actors/v4/actors/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/node/modules/dtypes" ) @@ -124,3 +127,20 @@ func (s *state4) AddressMapHashFunction() func(input []byte) []byte { return res[:] } } + +func (s *state4) ActorKey() string { + return actors.InitKey +} + +func (s *state4) ActorVersion() actorstypes.Version { + return actorstypes.Version4 +} + +func (s *state4) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/init/v5.go b/chain/actors/builtin/init/v5.go index 4cd26d2ad..b8a6438d7 100644 --- a/chain/actors/builtin/init/v5.go +++ b/chain/actors/builtin/init/v5.go @@ -2,6 +2,7 @@ package init import ( "crypto/sha256" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" @@ -9,10 +10,12 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin" init5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/init" adt5 "github.com/filecoin-project/specs-actors/v5/actors/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/node/modules/dtypes" ) @@ -124,3 +127,20 @@ func (s *state5) AddressMapHashFunction() func(input []byte) []byte { return res[:] } } + +func (s *state5) ActorKey() string { + return actors.InitKey +} + +func (s *state5) ActorVersion() actorstypes.Version { + return actorstypes.Version5 +} + +func (s *state5) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/init/v6.go b/chain/actors/builtin/init/v6.go index 4df3ffbc7..aeadc2caf 100644 --- a/chain/actors/builtin/init/v6.go +++ b/chain/actors/builtin/init/v6.go @@ -2,6 +2,7 @@ package init import ( "crypto/sha256" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" @@ -9,10 +10,12 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin" init6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/init" adt6 "github.com/filecoin-project/specs-actors/v6/actors/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/node/modules/dtypes" ) @@ -124,3 +127,20 @@ func (s *state6) AddressMapHashFunction() func(input []byte) []byte { return res[:] } } + +func (s *state6) ActorKey() string { + return actors.InitKey +} + +func (s *state6) ActorVersion() actorstypes.Version { + return actorstypes.Version6 +} + +func (s *state6) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/init/v7.go b/chain/actors/builtin/init/v7.go index 083424568..e62c56277 100644 --- a/chain/actors/builtin/init/v7.go +++ b/chain/actors/builtin/init/v7.go @@ -2,6 +2,7 @@ package init import ( "crypto/sha256" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" @@ -9,10 +10,12 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" init7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/init" adt7 "github.com/filecoin-project/specs-actors/v7/actors/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/node/modules/dtypes" ) @@ -124,3 +127,20 @@ func (s *state7) AddressMapHashFunction() func(input []byte) []byte { return res[:] } } + +func (s *state7) ActorKey() string { + return actors.InitKey +} + +func (s *state7) ActorVersion() actorstypes.Version { + return actorstypes.Version7 +} + +func (s *state7) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/init/v8.go b/chain/actors/builtin/init/v8.go index ea444acdf..145b75551 100644 --- a/chain/actors/builtin/init/v8.go +++ b/chain/actors/builtin/init/v8.go @@ -2,6 +2,7 @@ package init import ( "crypto/sha256" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" @@ -9,10 +10,12 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" builtin8 "github.com/filecoin-project/go-state-types/builtin" init8 "github.com/filecoin-project/go-state-types/builtin/v8/init" adt8 "github.com/filecoin-project/go-state-types/builtin/v8/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/node/modules/dtypes" ) @@ -124,3 +127,20 @@ func (s *state8) AddressMapHashFunction() func(input []byte) []byte { return res[:] } } + +func (s *state8) ActorKey() string { + return actors.InitKey +} + +func (s *state8) ActorVersion() actorstypes.Version { + return actorstypes.Version8 +} + +func (s *state8) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/init/v9.go b/chain/actors/builtin/init/v9.go index abc412ce6..8cba18e7a 100644 --- a/chain/actors/builtin/init/v9.go +++ b/chain/actors/builtin/init/v9.go @@ -2,6 +2,7 @@ package init import ( "crypto/sha256" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" @@ -9,10 +10,12 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" builtin9 "github.com/filecoin-project/go-state-types/builtin" init9 "github.com/filecoin-project/go-state-types/builtin/v9/init" adt9 "github.com/filecoin-project/go-state-types/builtin/v9/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/node/modules/dtypes" ) @@ -124,3 +127,20 @@ func (s *state9) AddressMapHashFunction() func(input []byte) []byte { return res[:] } } + +func (s *state9) ActorKey() string { + return actors.InitKey +} + +func (s *state9) ActorVersion() actorstypes.Version { + return actorstypes.Version9 +} + +func (s *state9) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/market/actor.go.template b/chain/actors/builtin/market/actor.go.template index fa0622ff0..b8d8c987b 100644 --- a/chain/actors/builtin/market/actor.go.template +++ b/chain/actors/builtin/market/actor.go.template @@ -1,6 +1,7 @@ package market import ( + "github.com/ipfs/go-cid" actorstypes "github.com/filecoin-project/go-state-types/actors" "unicode/utf8" @@ -73,6 +74,11 @@ func MakeState(store adt.Store, av actorstypes.Version) (State, error) { type State interface { cbor.Marshaler + + Code() cid.Cid + ActorKey() string + ActorVersion() actorstypes.Version + BalancesChanged(State) (bool, error) EscrowTable() (BalanceTable, error) LockedTable() (BalanceTable, error) @@ -200,3 +206,10 @@ func labelFromGoString(s string) (markettypes.DealLabel, error) { return markettypes.NewLabelFromBytes([]byte(s)) } } + +func AllCodes() []cid.Cid { + return []cid.Cid{ {{range .versions}} + (&state{{.}}{}).Code(), + {{- end}} + } +} diff --git a/chain/actors/builtin/market/market.go b/chain/actors/builtin/market/market.go index 0e095d282..3f15d6355 100644 --- a/chain/actors/builtin/market/market.go +++ b/chain/actors/builtin/market/market.go @@ -3,6 +3,7 @@ package market import ( "unicode/utf8" + "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" @@ -114,6 +115,11 @@ func MakeState(store adt.Store, av actorstypes.Version) (State, error) { type State interface { cbor.Marshaler + + Code() cid.Cid + ActorKey() string + ActorVersion() actorstypes.Version + BalancesChanged(State) (bool, error) EscrowTable() (BalanceTable, error) LockedTable() (BalanceTable, error) @@ -264,3 +270,17 @@ func labelFromGoString(s string) (markettypes.DealLabel, error) { return markettypes.NewLabelFromBytes([]byte(s)) } } + +func AllCodes() []cid.Cid { + return []cid.Cid{ + (&state0{}).Code(), + (&state2{}).Code(), + (&state3{}).Code(), + (&state4{}).Code(), + (&state5{}).Code(), + (&state6{}).Code(), + (&state7{}).Code(), + (&state8{}).Code(), + (&state9{}).Code(), + } +} diff --git a/chain/actors/builtin/market/state.go.template b/chain/actors/builtin/market/state.go.template index 50abdeb6b..bbce812f8 100644 --- a/chain/actors/builtin/market/state.go.template +++ b/chain/actors/builtin/market/state.go.template @@ -1,6 +1,7 @@ package market import ( + "fmt" "bytes" "github.com/filecoin-project/go-address" @@ -14,7 +15,9 @@ import ( {{end}} + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/lotus/chain/actors/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/types" verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" @@ -387,3 +390,21 @@ func (s *state{{.v}}) GetAllocationIdForPendingDeal(dealId abi.DealID) (verifreg return verifregtypes.AllocationId(allocationId), nil {{end}} } + + +func (s *state{{.v}}) ActorKey() string { + return actors.MarketKey +} + +func (s *state{{.v}}) ActorVersion() actorstypes.Version { + return actorstypes.Version{{.v}} +} + +func (s *state{{.v}}) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/market/v0.go b/chain/actors/builtin/market/v0.go index aa68049bb..fe50dc04e 100644 --- a/chain/actors/builtin/market/v0.go +++ b/chain/actors/builtin/market/v0.go @@ -2,6 +2,7 @@ package market import ( "bytes" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" @@ -9,10 +10,12 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" market0 "github.com/filecoin-project/specs-actors/actors/builtin/market" adt0 "github.com/filecoin-project/specs-actors/actors/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/types" ) @@ -307,3 +310,20 @@ func (s *state0) GetAllocationIdForPendingDeal(dealId abi.DealID) (verifregtypes return verifregtypes.NoAllocationID, xerrors.Errorf("unsupported before actors v9") } + +func (s *state0) ActorKey() string { + return actors.MarketKey +} + +func (s *state0) ActorVersion() actorstypes.Version { + return actorstypes.Version0 +} + +func (s *state0) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/market/v2.go b/chain/actors/builtin/market/v2.go index 777a17cd0..a10895dc7 100644 --- a/chain/actors/builtin/market/v2.go +++ b/chain/actors/builtin/market/v2.go @@ -2,6 +2,7 @@ package market import ( "bytes" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" @@ -9,10 +10,12 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" market2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/market" adt2 "github.com/filecoin-project/specs-actors/v2/actors/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/types" ) @@ -307,3 +310,20 @@ func (s *state2) GetAllocationIdForPendingDeal(dealId abi.DealID) (verifregtypes return verifregtypes.NoAllocationID, xerrors.Errorf("unsupported before actors v9") } + +func (s *state2) ActorKey() string { + return actors.MarketKey +} + +func (s *state2) ActorVersion() actorstypes.Version { + return actorstypes.Version2 +} + +func (s *state2) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/market/v3.go b/chain/actors/builtin/market/v3.go index 5ca09fdfb..c207ebab1 100644 --- a/chain/actors/builtin/market/v3.go +++ b/chain/actors/builtin/market/v3.go @@ -2,6 +2,7 @@ package market import ( "bytes" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" @@ -9,10 +10,12 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" market3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/market" adt3 "github.com/filecoin-project/specs-actors/v3/actors/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/types" ) @@ -302,3 +305,20 @@ func (s *state3) GetAllocationIdForPendingDeal(dealId abi.DealID) (verifregtypes return verifregtypes.NoAllocationID, xerrors.Errorf("unsupported before actors v9") } + +func (s *state3) ActorKey() string { + return actors.MarketKey +} + +func (s *state3) ActorVersion() actorstypes.Version { + return actorstypes.Version3 +} + +func (s *state3) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/market/v4.go b/chain/actors/builtin/market/v4.go index 23422ec31..e90f67720 100644 --- a/chain/actors/builtin/market/v4.go +++ b/chain/actors/builtin/market/v4.go @@ -2,6 +2,7 @@ package market import ( "bytes" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" @@ -9,10 +10,12 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" market4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/market" adt4 "github.com/filecoin-project/specs-actors/v4/actors/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/types" ) @@ -302,3 +305,20 @@ func (s *state4) GetAllocationIdForPendingDeal(dealId abi.DealID) (verifregtypes return verifregtypes.NoAllocationID, xerrors.Errorf("unsupported before actors v9") } + +func (s *state4) ActorKey() string { + return actors.MarketKey +} + +func (s *state4) ActorVersion() actorstypes.Version { + return actorstypes.Version4 +} + +func (s *state4) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/market/v5.go b/chain/actors/builtin/market/v5.go index 8e8833c37..0015389b0 100644 --- a/chain/actors/builtin/market/v5.go +++ b/chain/actors/builtin/market/v5.go @@ -2,6 +2,7 @@ package market import ( "bytes" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" @@ -9,10 +10,12 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" market5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/market" adt5 "github.com/filecoin-project/specs-actors/v5/actors/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/types" ) @@ -302,3 +305,20 @@ func (s *state5) GetAllocationIdForPendingDeal(dealId abi.DealID) (verifregtypes return verifregtypes.NoAllocationID, xerrors.Errorf("unsupported before actors v9") } + +func (s *state5) ActorKey() string { + return actors.MarketKey +} + +func (s *state5) ActorVersion() actorstypes.Version { + return actorstypes.Version5 +} + +func (s *state5) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/market/v6.go b/chain/actors/builtin/market/v6.go index d86f73108..0856bed48 100644 --- a/chain/actors/builtin/market/v6.go +++ b/chain/actors/builtin/market/v6.go @@ -2,6 +2,7 @@ package market import ( "bytes" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" @@ -11,10 +12,12 @@ import ( "github.com/filecoin-project/go-bitfield" rlepluslazy "github.com/filecoin-project/go-bitfield/rle" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" market6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/market" adt6 "github.com/filecoin-project/specs-actors/v6/actors/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/types" ) @@ -320,3 +323,20 @@ func (s *state6) GetAllocationIdForPendingDeal(dealId abi.DealID) (verifregtypes return verifregtypes.NoAllocationID, xerrors.Errorf("unsupported before actors v9") } + +func (s *state6) ActorKey() string { + return actors.MarketKey +} + +func (s *state6) ActorVersion() actorstypes.Version { + return actorstypes.Version6 +} + +func (s *state6) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/market/v7.go b/chain/actors/builtin/market/v7.go index 5f6547e3f..3df6cef31 100644 --- a/chain/actors/builtin/market/v7.go +++ b/chain/actors/builtin/market/v7.go @@ -2,6 +2,7 @@ package market import ( "bytes" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" @@ -11,10 +12,12 @@ import ( "github.com/filecoin-project/go-bitfield" rlepluslazy "github.com/filecoin-project/go-bitfield/rle" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" market7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/market" adt7 "github.com/filecoin-project/specs-actors/v7/actors/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/types" ) @@ -320,3 +323,20 @@ func (s *state7) GetAllocationIdForPendingDeal(dealId abi.DealID) (verifregtypes return verifregtypes.NoAllocationID, xerrors.Errorf("unsupported before actors v9") } + +func (s *state7) ActorKey() string { + return actors.MarketKey +} + +func (s *state7) ActorVersion() actorstypes.Version { + return actorstypes.Version7 +} + +func (s *state7) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/market/v8.go b/chain/actors/builtin/market/v8.go index 5f3b690bb..c73eed137 100644 --- a/chain/actors/builtin/market/v8.go +++ b/chain/actors/builtin/market/v8.go @@ -2,6 +2,7 @@ package market import ( "bytes" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" @@ -11,11 +12,13 @@ import ( "github.com/filecoin-project/go-bitfield" rlepluslazy "github.com/filecoin-project/go-bitfield/rle" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" market8 "github.com/filecoin-project/go-state-types/builtin/v8/market" adt8 "github.com/filecoin-project/go-state-types/builtin/v8/util/adt" markettypes "github.com/filecoin-project/go-state-types/builtin/v9/market" verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/types" ) @@ -337,3 +340,20 @@ func (s *state8) GetAllocationIdForPendingDeal(dealId abi.DealID) (verifregtypes return verifregtypes.NoAllocationID, xerrors.Errorf("unsupported before actors v9") } + +func (s *state8) ActorKey() string { + return actors.MarketKey +} + +func (s *state8) ActorVersion() actorstypes.Version { + return actorstypes.Version8 +} + +func (s *state8) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/market/v9.go b/chain/actors/builtin/market/v9.go index 9fed45ae8..230ea5a01 100644 --- a/chain/actors/builtin/market/v9.go +++ b/chain/actors/builtin/market/v9.go @@ -2,6 +2,7 @@ package market import ( "bytes" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" @@ -11,12 +12,14 @@ import ( "github.com/filecoin-project/go-bitfield" rlepluslazy "github.com/filecoin-project/go-bitfield/rle" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/builtin" market9 "github.com/filecoin-project/go-state-types/builtin/v9/market" markettypes "github.com/filecoin-project/go-state-types/builtin/v9/market" adt9 "github.com/filecoin-project/go-state-types/builtin/v9/util/adt" verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/types" ) @@ -347,3 +350,20 @@ func (s *state9) GetAllocationIdForPendingDeal(dealId abi.DealID) (verifregtypes return verifregtypes.AllocationId(allocationId), nil } + +func (s *state9) ActorKey() string { + return actors.MarketKey +} + +func (s *state9) ActorVersion() actorstypes.Version { + return actorstypes.Version9 +} + +func (s *state9) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/miner/actor.go.template b/chain/actors/builtin/miner/actor.go.template index 751ab698f..c23cbec7e 100644 --- a/chain/actors/builtin/miner/actor.go.template +++ b/chain/actors/builtin/miner/actor.go.template @@ -1,6 +1,7 @@ package miner import ( + "github.com/ipfs/go-cid" actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/network" @@ -66,6 +67,10 @@ func MakeState(store adt.Store, av actors.Version) (State, error) { type State interface { cbor.Marshaler + Code() cid.Cid + ActorKey() string + ActorVersion() actorstypes.Version + // Total available balance to spend. AvailableBalance(abi.TokenAmount) (abi.TokenAmount, error) // Funds that will vest by the given epoch. @@ -243,3 +248,10 @@ type LockedFunds struct { func (lf LockedFunds) TotalLockedFunds() abi.TokenAmount { return big.Add(lf.VestingFunds, big.Add(lf.InitialPledgeRequirement, lf.PreCommitDeposits)) } + +func AllCodes() []cid.Cid { + return []cid.Cid{ {{range .versions}} + (&state{{.}}{}).Code(), + {{- end}} + } +} diff --git a/chain/actors/builtin/miner/miner.go b/chain/actors/builtin/miner/miner.go index c3db4cb0e..65bf97e37 100644 --- a/chain/actors/builtin/miner/miner.go +++ b/chain/actors/builtin/miner/miner.go @@ -1,6 +1,7 @@ package miner import ( + "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" @@ -108,6 +109,10 @@ func MakeState(store adt.Store, av actors.Version) (State, error) { type State interface { cbor.Marshaler + Code() cid.Cid + ActorKey() string + ActorVersion() actorstypes.Version + // Total available balance to spend. AvailableBalance(abi.TokenAmount) (abi.TokenAmount, error) // Funds that will vest by the given epoch. @@ -285,3 +290,17 @@ type LockedFunds struct { func (lf LockedFunds) TotalLockedFunds() abi.TokenAmount { return big.Add(lf.VestingFunds, big.Add(lf.InitialPledgeRequirement, lf.PreCommitDeposits)) } + +func AllCodes() []cid.Cid { + return []cid.Cid{ + (&state0{}).Code(), + (&state2{}).Code(), + (&state3{}).Code(), + (&state4{}).Code(), + (&state5{}).Code(), + (&state6{}).Code(), + (&state7{}).Code(), + (&state8{}).Code(), + (&state9{}).Code(), + } +} diff --git a/chain/actors/builtin/miner/state.go.template b/chain/actors/builtin/miner/state.go.template index 16c9c75e7..8fae02565 100644 --- a/chain/actors/builtin/miner/state.go.template +++ b/chain/actors/builtin/miner/state.go.template @@ -1,6 +1,7 @@ package miner import ( + "fmt" "bytes" "errors" {{if (le .v 1)}} @@ -15,6 +16,8 @@ import ( "golang.org/x/xerrors" "github.com/filecoin-project/lotus/chain/actors/adt" + "github.com/filecoin-project/lotus/chain/actors" + actorstypes "github.com/filecoin-project/go-state-types/actors" minertypes "github.com/filecoin-project/go-state-types/builtin/v{{.latestVersion}}/miner" {{if (le .v 7)}} @@ -602,3 +605,20 @@ func fromV{{.v}}SectorPreCommitOnChainInfo(v{{.v}} miner{{.v}}.SectorPreCommitOn func (s *state{{.v}}) GetState() interface{} { return &s.State } + +func (s *state{{.v}}) ActorKey() string { + return actors.MinerKey +} + +func (s *state{{.v}}) ActorVersion() actorstypes.Version { + return actorstypes.Version{{.v}} +} + +func (s *state{{.v}}) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/miner/v0.go b/chain/actors/builtin/miner/v0.go index e815806bd..e518ba82e 100644 --- a/chain/actors/builtin/miner/v0.go +++ b/chain/actors/builtin/miner/v0.go @@ -3,6 +3,7 @@ package miner import ( "bytes" "errors" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" @@ -11,12 +12,14 @@ import ( "github.com/filecoin-project/go-bitfield" rle "github.com/filecoin-project/go-bitfield/rle" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/dline" miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner" adt0 "github.com/filecoin-project/specs-actors/actors/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -528,3 +531,20 @@ func fromV0SectorPreCommitOnChainInfo(v0 miner0.SectorPreCommitOnChainInfo) mine func (s *state0) GetState() interface{} { return &s.State } + +func (s *state0) ActorKey() string { + return actors.MinerKey +} + +func (s *state0) ActorVersion() actorstypes.Version { + return actorstypes.Version0 +} + +func (s *state0) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/miner/v2.go b/chain/actors/builtin/miner/v2.go index 3501e81f1..48a46ba7c 100644 --- a/chain/actors/builtin/miner/v2.go +++ b/chain/actors/builtin/miner/v2.go @@ -3,6 +3,7 @@ package miner import ( "bytes" "errors" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" @@ -11,11 +12,13 @@ import ( "github.com/filecoin-project/go-bitfield" rle "github.com/filecoin-project/go-bitfield/rle" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/dline" miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner" adt2 "github.com/filecoin-project/specs-actors/v2/actors/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -559,3 +562,20 @@ func fromV2SectorPreCommitOnChainInfo(v2 miner2.SectorPreCommitOnChainInfo) mine func (s *state2) GetState() interface{} { return &s.State } + +func (s *state2) ActorKey() string { + return actors.MinerKey +} + +func (s *state2) ActorVersion() actorstypes.Version { + return actorstypes.Version2 +} + +func (s *state2) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/miner/v3.go b/chain/actors/builtin/miner/v3.go index 5d2d3ef61..77490ec6b 100644 --- a/chain/actors/builtin/miner/v3.go +++ b/chain/actors/builtin/miner/v3.go @@ -3,6 +3,7 @@ package miner import ( "bytes" "errors" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" @@ -11,12 +12,14 @@ import ( "github.com/filecoin-project/go-bitfield" rle "github.com/filecoin-project/go-bitfield/rle" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/dline" builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin" miner3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/miner" adt3 "github.com/filecoin-project/specs-actors/v3/actors/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -559,3 +562,20 @@ func fromV3SectorPreCommitOnChainInfo(v3 miner3.SectorPreCommitOnChainInfo) mine func (s *state3) GetState() interface{} { return &s.State } + +func (s *state3) ActorKey() string { + return actors.MinerKey +} + +func (s *state3) ActorVersion() actorstypes.Version { + return actorstypes.Version3 +} + +func (s *state3) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/miner/v4.go b/chain/actors/builtin/miner/v4.go index db36c3875..0120d5913 100644 --- a/chain/actors/builtin/miner/v4.go +++ b/chain/actors/builtin/miner/v4.go @@ -3,6 +3,7 @@ package miner import ( "bytes" "errors" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" @@ -11,12 +12,14 @@ import ( "github.com/filecoin-project/go-bitfield" rle "github.com/filecoin-project/go-bitfield/rle" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/dline" builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin" miner4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/miner" adt4 "github.com/filecoin-project/specs-actors/v4/actors/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -559,3 +562,20 @@ func fromV4SectorPreCommitOnChainInfo(v4 miner4.SectorPreCommitOnChainInfo) mine func (s *state4) GetState() interface{} { return &s.State } + +func (s *state4) ActorKey() string { + return actors.MinerKey +} + +func (s *state4) ActorVersion() actorstypes.Version { + return actorstypes.Version4 +} + +func (s *state4) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/miner/v5.go b/chain/actors/builtin/miner/v5.go index 8ff6432d2..6d834be76 100644 --- a/chain/actors/builtin/miner/v5.go +++ b/chain/actors/builtin/miner/v5.go @@ -3,6 +3,7 @@ package miner import ( "bytes" "errors" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" @@ -11,12 +12,14 @@ import ( "github.com/filecoin-project/go-bitfield" rle "github.com/filecoin-project/go-bitfield/rle" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/dline" builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin" miner5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/miner" adt5 "github.com/filecoin-project/specs-actors/v5/actors/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -559,3 +562,20 @@ func fromV5SectorPreCommitOnChainInfo(v5 miner5.SectorPreCommitOnChainInfo) mine func (s *state5) GetState() interface{} { return &s.State } + +func (s *state5) ActorKey() string { + return actors.MinerKey +} + +func (s *state5) ActorVersion() actorstypes.Version { + return actorstypes.Version5 +} + +func (s *state5) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/miner/v6.go b/chain/actors/builtin/miner/v6.go index f11d4d062..2f1ae310a 100644 --- a/chain/actors/builtin/miner/v6.go +++ b/chain/actors/builtin/miner/v6.go @@ -3,6 +3,7 @@ package miner import ( "bytes" "errors" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" @@ -11,12 +12,14 @@ import ( "github.com/filecoin-project/go-bitfield" rle "github.com/filecoin-project/go-bitfield/rle" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/dline" builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin" miner6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/miner" adt6 "github.com/filecoin-project/specs-actors/v6/actors/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -559,3 +562,20 @@ func fromV6SectorPreCommitOnChainInfo(v6 miner6.SectorPreCommitOnChainInfo) mine func (s *state6) GetState() interface{} { return &s.State } + +func (s *state6) ActorKey() string { + return actors.MinerKey +} + +func (s *state6) ActorVersion() actorstypes.Version { + return actorstypes.Version6 +} + +func (s *state6) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/miner/v7.go b/chain/actors/builtin/miner/v7.go index f7893cef3..f876d1d85 100644 --- a/chain/actors/builtin/miner/v7.go +++ b/chain/actors/builtin/miner/v7.go @@ -3,6 +3,7 @@ package miner import ( "bytes" "errors" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" @@ -11,12 +12,14 @@ import ( "github.com/filecoin-project/go-bitfield" rle "github.com/filecoin-project/go-bitfield/rle" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/dline" builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" miner7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/miner" adt7 "github.com/filecoin-project/specs-actors/v7/actors/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -560,3 +563,20 @@ func fromV7SectorPreCommitOnChainInfo(v7 miner7.SectorPreCommitOnChainInfo) mine func (s *state7) GetState() interface{} { return &s.State } + +func (s *state7) ActorKey() string { + return actors.MinerKey +} + +func (s *state7) ActorVersion() actorstypes.Version { + return actorstypes.Version7 +} + +func (s *state7) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/miner/v8.go b/chain/actors/builtin/miner/v8.go index 0d53cc664..21d5b1cbf 100644 --- a/chain/actors/builtin/miner/v8.go +++ b/chain/actors/builtin/miner/v8.go @@ -3,6 +3,7 @@ package miner import ( "bytes" "errors" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" @@ -11,12 +12,14 @@ import ( "github.com/filecoin-project/go-bitfield" rle "github.com/filecoin-project/go-bitfield/rle" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" builtin8 "github.com/filecoin-project/go-state-types/builtin" miner8 "github.com/filecoin-project/go-state-types/builtin/v8/miner" adt8 "github.com/filecoin-project/go-state-types/builtin/v8/util/adt" minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/dline" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -560,3 +563,20 @@ func fromV8SectorPreCommitOnChainInfo(v8 miner8.SectorPreCommitOnChainInfo) mine func (s *state8) GetState() interface{} { return &s.State } + +func (s *state8) ActorKey() string { + return actors.MinerKey +} + +func (s *state8) ActorVersion() actorstypes.Version { + return actorstypes.Version8 +} + +func (s *state8) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/miner/v9.go b/chain/actors/builtin/miner/v9.go index 32b8d008b..3fba60164 100644 --- a/chain/actors/builtin/miner/v9.go +++ b/chain/actors/builtin/miner/v9.go @@ -3,6 +3,7 @@ package miner import ( "bytes" "errors" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" @@ -11,12 +12,14 @@ import ( "github.com/filecoin-project/go-bitfield" rle "github.com/filecoin-project/go-bitfield/rle" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" builtin9 "github.com/filecoin-project/go-state-types/builtin" miner9 "github.com/filecoin-project/go-state-types/builtin/v9/miner" minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner" adt9 "github.com/filecoin-project/go-state-types/builtin/v9/util/adt" "github.com/filecoin-project/go-state-types/dline" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -552,3 +555,20 @@ func fromV9SectorPreCommitOnChainInfo(v9 miner9.SectorPreCommitOnChainInfo) mine func (s *state9) GetState() interface{} { return &s.State } + +func (s *state9) ActorKey() string { + return actors.MinerKey +} + +func (s *state9) ActorVersion() actorstypes.Version { + return actorstypes.Version9 +} + +func (s *state9) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/multisig/actor.go.template b/chain/actors/builtin/multisig/actor.go.template index a02a986aa..40e49e702 100644 --- a/chain/actors/builtin/multisig/actor.go.template +++ b/chain/actors/builtin/multisig/actor.go.template @@ -2,6 +2,7 @@ package multisig import ( actorstypes "github.com/filecoin-project/go-state-types/actors" + "github.com/ipfs/go-cid" "fmt" "github.com/minio/blake2b-simd" @@ -67,6 +68,10 @@ func MakeState(store adt.Store, av actorstypes.Version, signers []address.Addres type State interface { cbor.Marshaler + Code() cid.Cid + ActorKey() string + ActorVersion() actorstypes.Version + LockedBalance(epoch abi.ChainEpoch) (abi.TokenAmount, error) StartEpoch() (abi.ChainEpoch, error) UnlockDuration() (abi.ChainEpoch, error) @@ -141,3 +146,10 @@ func txnParams(id uint64, data *ProposalHashData) ([]byte, error) { return actors.SerializeParams(¶ms) } + +func AllCodes() []cid.Cid { + return []cid.Cid{ {{range .versions}} + (&state{{.}}{}).Code(), + {{- end}} + } +} diff --git a/chain/actors/builtin/multisig/multisig.go b/chain/actors/builtin/multisig/multisig.go index 6c0d449df..45e196b24 100644 --- a/chain/actors/builtin/multisig/multisig.go +++ b/chain/actors/builtin/multisig/multisig.go @@ -3,6 +3,7 @@ package multisig import ( "fmt" + "github.com/ipfs/go-cid" "github.com/minio/blake2b-simd" cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" @@ -108,6 +109,10 @@ func MakeState(store adt.Store, av actorstypes.Version, signers []address.Addres type State interface { cbor.Marshaler + Code() cid.Cid + ActorKey() string + ActorVersion() actorstypes.Version + LockedBalance(epoch abi.ChainEpoch) (abi.TokenAmount, error) StartEpoch() (abi.ChainEpoch, error) UnlockDuration() (abi.ChainEpoch, error) @@ -206,3 +211,17 @@ func txnParams(id uint64, data *ProposalHashData) ([]byte, error) { return actors.SerializeParams(¶ms) } + +func AllCodes() []cid.Cid { + return []cid.Cid{ + (&state0{}).Code(), + (&state2{}).Code(), + (&state3{}).Code(), + (&state4{}).Code(), + (&state5{}).Code(), + (&state6{}).Code(), + (&state7{}).Code(), + (&state8{}).Code(), + (&state9{}).Code(), + } +} diff --git a/chain/actors/builtin/multisig/state.go.template b/chain/actors/builtin/multisig/state.go.template index e375becc3..457e8cb4d 100644 --- a/chain/actors/builtin/multisig/state.go.template +++ b/chain/actors/builtin/multisig/state.go.template @@ -1,9 +1,11 @@ package multisig import ( + "fmt" "bytes" "encoding/binary" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" @@ -12,6 +14,7 @@ import ( "golang.org/x/xerrors" "github.com/filecoin-project/lotus/chain/actors/adt" + "github.com/filecoin-project/lotus/chain/actors" {{if (le .v 7)}} {{if (ge .v 3)}} @@ -131,3 +134,20 @@ func (s *state{{.v}}) decodeTransaction(val *cbg.Deferred) (Transaction, error) func (s *state{{.v}}) GetState() interface{} { return &s.State } + +func (s *state{{.v}}) ActorKey() string { + return actors.MultisigKey +} + +func (s *state{{.v}}) ActorVersion() actorstypes.Version { + return actorstypes.Version{{.v}} +} + +func (s *state{{.v}}) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/multisig/v0.go b/chain/actors/builtin/multisig/v0.go index 9f4d09dc1..38cc76411 100644 --- a/chain/actors/builtin/multisig/v0.go +++ b/chain/actors/builtin/multisig/v0.go @@ -3,6 +3,7 @@ package multisig import ( "bytes" "encoding/binary" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" @@ -10,9 +11,11 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" msig0 "github.com/filecoin-project/specs-actors/actors/builtin/multisig" adt0 "github.com/filecoin-project/specs-actors/actors/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -114,3 +117,20 @@ func (s *state0) decodeTransaction(val *cbg.Deferred) (Transaction, error) { func (s *state0) GetState() interface{} { return &s.State } + +func (s *state0) ActorKey() string { + return actors.MultisigKey +} + +func (s *state0) ActorVersion() actorstypes.Version { + return actorstypes.Version0 +} + +func (s *state0) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/multisig/v2.go b/chain/actors/builtin/multisig/v2.go index 14e895680..2d72b3215 100644 --- a/chain/actors/builtin/multisig/v2.go +++ b/chain/actors/builtin/multisig/v2.go @@ -3,6 +3,7 @@ package multisig import ( "bytes" "encoding/binary" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" @@ -10,9 +11,11 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" msig2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/multisig" adt2 "github.com/filecoin-project/specs-actors/v2/actors/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -114,3 +117,20 @@ func (s *state2) decodeTransaction(val *cbg.Deferred) (Transaction, error) { func (s *state2) GetState() interface{} { return &s.State } + +func (s *state2) ActorKey() string { + return actors.MultisigKey +} + +func (s *state2) ActorVersion() actorstypes.Version { + return actorstypes.Version2 +} + +func (s *state2) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/multisig/v3.go b/chain/actors/builtin/multisig/v3.go index 5cde148c1..bd45ecdaa 100644 --- a/chain/actors/builtin/multisig/v3.go +++ b/chain/actors/builtin/multisig/v3.go @@ -3,6 +3,7 @@ package multisig import ( "bytes" "encoding/binary" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" @@ -10,10 +11,12 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin" msig3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/multisig" adt3 "github.com/filecoin-project/specs-actors/v3/actors/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -115,3 +118,20 @@ func (s *state3) decodeTransaction(val *cbg.Deferred) (Transaction, error) { func (s *state3) GetState() interface{} { return &s.State } + +func (s *state3) ActorKey() string { + return actors.MultisigKey +} + +func (s *state3) ActorVersion() actorstypes.Version { + return actorstypes.Version3 +} + +func (s *state3) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/multisig/v4.go b/chain/actors/builtin/multisig/v4.go index 87936661d..1f5f2a9ce 100644 --- a/chain/actors/builtin/multisig/v4.go +++ b/chain/actors/builtin/multisig/v4.go @@ -3,6 +3,7 @@ package multisig import ( "bytes" "encoding/binary" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" @@ -10,10 +11,12 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin" msig4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/multisig" adt4 "github.com/filecoin-project/specs-actors/v4/actors/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -115,3 +118,20 @@ func (s *state4) decodeTransaction(val *cbg.Deferred) (Transaction, error) { func (s *state4) GetState() interface{} { return &s.State } + +func (s *state4) ActorKey() string { + return actors.MultisigKey +} + +func (s *state4) ActorVersion() actorstypes.Version { + return actorstypes.Version4 +} + +func (s *state4) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/multisig/v5.go b/chain/actors/builtin/multisig/v5.go index d50638ca5..bf4a58cbf 100644 --- a/chain/actors/builtin/multisig/v5.go +++ b/chain/actors/builtin/multisig/v5.go @@ -3,6 +3,7 @@ package multisig import ( "bytes" "encoding/binary" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" @@ -10,10 +11,12 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin" msig5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/multisig" adt5 "github.com/filecoin-project/specs-actors/v5/actors/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -115,3 +118,20 @@ func (s *state5) decodeTransaction(val *cbg.Deferred) (Transaction, error) { func (s *state5) GetState() interface{} { return &s.State } + +func (s *state5) ActorKey() string { + return actors.MultisigKey +} + +func (s *state5) ActorVersion() actorstypes.Version { + return actorstypes.Version5 +} + +func (s *state5) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/multisig/v6.go b/chain/actors/builtin/multisig/v6.go index 9246eeaa9..f5c6f66bb 100644 --- a/chain/actors/builtin/multisig/v6.go +++ b/chain/actors/builtin/multisig/v6.go @@ -3,6 +3,7 @@ package multisig import ( "bytes" "encoding/binary" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" @@ -10,10 +11,12 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin" msig6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/multisig" adt6 "github.com/filecoin-project/specs-actors/v6/actors/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -115,3 +118,20 @@ func (s *state6) decodeTransaction(val *cbg.Deferred) (Transaction, error) { func (s *state6) GetState() interface{} { return &s.State } + +func (s *state6) ActorKey() string { + return actors.MultisigKey +} + +func (s *state6) ActorVersion() actorstypes.Version { + return actorstypes.Version6 +} + +func (s *state6) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/multisig/v7.go b/chain/actors/builtin/multisig/v7.go index a6b630179..e75865841 100644 --- a/chain/actors/builtin/multisig/v7.go +++ b/chain/actors/builtin/multisig/v7.go @@ -3,6 +3,7 @@ package multisig import ( "bytes" "encoding/binary" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" @@ -10,10 +11,12 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" msig7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/multisig" adt7 "github.com/filecoin-project/specs-actors/v7/actors/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -115,3 +118,20 @@ func (s *state7) decodeTransaction(val *cbg.Deferred) (Transaction, error) { func (s *state7) GetState() interface{} { return &s.State } + +func (s *state7) ActorKey() string { + return actors.MultisigKey +} + +func (s *state7) ActorVersion() actorstypes.Version { + return actorstypes.Version7 +} + +func (s *state7) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/multisig/v8.go b/chain/actors/builtin/multisig/v8.go index 6311583b3..677f4ffe9 100644 --- a/chain/actors/builtin/multisig/v8.go +++ b/chain/actors/builtin/multisig/v8.go @@ -3,6 +3,7 @@ package multisig import ( "bytes" "encoding/binary" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" @@ -10,10 +11,12 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" builtin8 "github.com/filecoin-project/go-state-types/builtin" msig8 "github.com/filecoin-project/go-state-types/builtin/v8/multisig" adt8 "github.com/filecoin-project/go-state-types/builtin/v8/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -115,3 +118,20 @@ func (s *state8) decodeTransaction(val *cbg.Deferred) (Transaction, error) { func (s *state8) GetState() interface{} { return &s.State } + +func (s *state8) ActorKey() string { + return actors.MultisigKey +} + +func (s *state8) ActorVersion() actorstypes.Version { + return actorstypes.Version8 +} + +func (s *state8) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/multisig/v9.go b/chain/actors/builtin/multisig/v9.go index ef9a48f28..2700470d3 100644 --- a/chain/actors/builtin/multisig/v9.go +++ b/chain/actors/builtin/multisig/v9.go @@ -3,6 +3,7 @@ package multisig import ( "bytes" "encoding/binary" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" @@ -10,10 +11,12 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" builtin9 "github.com/filecoin-project/go-state-types/builtin" msig9 "github.com/filecoin-project/go-state-types/builtin/v9/multisig" adt9 "github.com/filecoin-project/go-state-types/builtin/v9/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -115,3 +118,20 @@ func (s *state9) decodeTransaction(val *cbg.Deferred) (Transaction, error) { func (s *state9) GetState() interface{} { return &s.State } + +func (s *state9) ActorKey() string { + return actors.MultisigKey +} + +func (s *state9) ActorVersion() actorstypes.Version { + return actorstypes.Version9 +} + +func (s *state9) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/paych/actor.go.template b/chain/actors/builtin/paych/actor.go.template index 1308d4ea4..4250b4770 100644 --- a/chain/actors/builtin/paych/actor.go.template +++ b/chain/actors/builtin/paych/actor.go.template @@ -1,7 +1,9 @@ package paych import ( + "github.com/ipfs/go-cid" actorstypes "github.com/filecoin-project/go-state-types/actors" + "github.com/ipfs/go-cid" "encoding/base64" "fmt" @@ -59,6 +61,11 @@ func Load(store adt.Store, act *types.Actor) (State, error) { // versions type State interface { cbor.Marshaler + + Code() cid.Cid + ActorKey() string + ActorVersion() actorstypes.Version + // Channel owner, who has funded the actor From() (address.Address, error) // Recipient of payouts from channel @@ -132,4 +139,11 @@ func toV0SignedVoucher(sv paychtypes.SignedVoucher) paych0.SignedVoucher { Merges: nil, Signature: sv.Signature, } -} \ No newline at end of file +} + +func AllCodes() []cid.Cid { + return []cid.Cid{ {{range .versions}} + (&state{{.}}{}).Code(), + {{- end}} + } +} diff --git a/chain/actors/builtin/paych/paych.go b/chain/actors/builtin/paych/paych.go index e0a13fd21..2e93ceb3f 100644 --- a/chain/actors/builtin/paych/paych.go +++ b/chain/actors/builtin/paych/paych.go @@ -4,6 +4,7 @@ import ( "encoding/base64" "fmt" + "github.com/ipfs/go-cid" ipldcbor "github.com/ipfs/go-ipld-cbor" "golang.org/x/xerrors" @@ -77,6 +78,11 @@ func Load(store adt.Store, act *types.Actor) (State, error) { // versions type State interface { cbor.Marshaler + + Code() cid.Cid + ActorKey() string + ActorVersion() actorstypes.Version + // Channel owner, who has funded the actor From() (address.Address, error) // Recipient of payouts from channel @@ -175,3 +181,17 @@ func toV0SignedVoucher(sv paychtypes.SignedVoucher) paych0.SignedVoucher { Signature: sv.Signature, } } + +func AllCodes() []cid.Cid { + return []cid.Cid{ + (&state0{}).Code(), + (&state2{}).Code(), + (&state3{}).Code(), + (&state4{}).Code(), + (&state5{}).Code(), + (&state6{}).Code(), + (&state7{}).Code(), + (&state8{}).Code(), + (&state9{}).Code(), + } +} diff --git a/chain/actors/builtin/paych/state.go.template b/chain/actors/builtin/paych/state.go.template index c3954ce81..c00f7dc56 100644 --- a/chain/actors/builtin/paych/state.go.template +++ b/chain/actors/builtin/paych/state.go.template @@ -1,6 +1,8 @@ package paych import ( + "fmt" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/ipfs/go-cid" "github.com/filecoin-project/go-address" @@ -8,6 +10,7 @@ import ( "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/lotus/chain/actors/adt" + "github.com/filecoin-project/lotus/chain/actors" {{if (le .v 7)}} paych{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/paych" @@ -117,3 +120,20 @@ func (ls *laneState{{.v}}) Redeemed() (big.Int, error) { func (ls *laneState{{.v}}) Nonce() (uint64, error) { return ls.LaneState.Nonce, nil } + +func (s *state{{.v}}) ActorKey() string { + return actors.PaychKey +} + +func (s *state{{.v}}) ActorVersion() actorstypes.Version { + return actorstypes.Version{{.v}} +} + +func (s *state{{.v}}) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/paych/v0.go b/chain/actors/builtin/paych/v0.go index 727525c50..8cdc27c39 100644 --- a/chain/actors/builtin/paych/v0.go +++ b/chain/actors/builtin/paych/v0.go @@ -1,14 +1,18 @@ package paych import ( + "fmt" + "github.com/ipfs/go-cid" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" paych0 "github.com/filecoin-project/specs-actors/actors/builtin/paych" adt0 "github.com/filecoin-project/specs-actors/actors/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -111,3 +115,20 @@ func (ls *laneState0) Redeemed() (big.Int, error) { func (ls *laneState0) Nonce() (uint64, error) { return ls.LaneState.Nonce, nil } + +func (s *state0) ActorKey() string { + return actors.PaychKey +} + +func (s *state0) ActorVersion() actorstypes.Version { + return actorstypes.Version0 +} + +func (s *state0) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/paych/v2.go b/chain/actors/builtin/paych/v2.go index 5852c9a64..ae94adc17 100644 --- a/chain/actors/builtin/paych/v2.go +++ b/chain/actors/builtin/paych/v2.go @@ -1,14 +1,18 @@ package paych import ( + "fmt" + "github.com/ipfs/go-cid" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" paych2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/paych" adt2 "github.com/filecoin-project/specs-actors/v2/actors/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -111,3 +115,20 @@ func (ls *laneState2) Redeemed() (big.Int, error) { func (ls *laneState2) Nonce() (uint64, error) { return ls.LaneState.Nonce, nil } + +func (s *state2) ActorKey() string { + return actors.PaychKey +} + +func (s *state2) ActorVersion() actorstypes.Version { + return actorstypes.Version2 +} + +func (s *state2) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/paych/v3.go b/chain/actors/builtin/paych/v3.go index 5297e9d10..5c57ea729 100644 --- a/chain/actors/builtin/paych/v3.go +++ b/chain/actors/builtin/paych/v3.go @@ -1,14 +1,18 @@ package paych import ( + "fmt" + "github.com/ipfs/go-cid" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" paych3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/paych" adt3 "github.com/filecoin-project/specs-actors/v3/actors/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -111,3 +115,20 @@ func (ls *laneState3) Redeemed() (big.Int, error) { func (ls *laneState3) Nonce() (uint64, error) { return ls.LaneState.Nonce, nil } + +func (s *state3) ActorKey() string { + return actors.PaychKey +} + +func (s *state3) ActorVersion() actorstypes.Version { + return actorstypes.Version3 +} + +func (s *state3) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/paych/v4.go b/chain/actors/builtin/paych/v4.go index be10061bf..b243be2e3 100644 --- a/chain/actors/builtin/paych/v4.go +++ b/chain/actors/builtin/paych/v4.go @@ -1,14 +1,18 @@ package paych import ( + "fmt" + "github.com/ipfs/go-cid" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" paych4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/paych" adt4 "github.com/filecoin-project/specs-actors/v4/actors/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -111,3 +115,20 @@ func (ls *laneState4) Redeemed() (big.Int, error) { func (ls *laneState4) Nonce() (uint64, error) { return ls.LaneState.Nonce, nil } + +func (s *state4) ActorKey() string { + return actors.PaychKey +} + +func (s *state4) ActorVersion() actorstypes.Version { + return actorstypes.Version4 +} + +func (s *state4) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/paych/v5.go b/chain/actors/builtin/paych/v5.go index 37a917273..b3b9ad50e 100644 --- a/chain/actors/builtin/paych/v5.go +++ b/chain/actors/builtin/paych/v5.go @@ -1,14 +1,18 @@ package paych import ( + "fmt" + "github.com/ipfs/go-cid" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" paych5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/paych" adt5 "github.com/filecoin-project/specs-actors/v5/actors/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -111,3 +115,20 @@ func (ls *laneState5) Redeemed() (big.Int, error) { func (ls *laneState5) Nonce() (uint64, error) { return ls.LaneState.Nonce, nil } + +func (s *state5) ActorKey() string { + return actors.PaychKey +} + +func (s *state5) ActorVersion() actorstypes.Version { + return actorstypes.Version5 +} + +func (s *state5) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/paych/v6.go b/chain/actors/builtin/paych/v6.go index 36676d9de..a3b80c8e1 100644 --- a/chain/actors/builtin/paych/v6.go +++ b/chain/actors/builtin/paych/v6.go @@ -1,14 +1,18 @@ package paych import ( + "fmt" + "github.com/ipfs/go-cid" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" paych6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/paych" adt6 "github.com/filecoin-project/specs-actors/v6/actors/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -111,3 +115,20 @@ func (ls *laneState6) Redeemed() (big.Int, error) { func (ls *laneState6) Nonce() (uint64, error) { return ls.LaneState.Nonce, nil } + +func (s *state6) ActorKey() string { + return actors.PaychKey +} + +func (s *state6) ActorVersion() actorstypes.Version { + return actorstypes.Version6 +} + +func (s *state6) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/paych/v7.go b/chain/actors/builtin/paych/v7.go index 88b6f2b84..bb6721b01 100644 --- a/chain/actors/builtin/paych/v7.go +++ b/chain/actors/builtin/paych/v7.go @@ -1,14 +1,18 @@ package paych import ( + "fmt" + "github.com/ipfs/go-cid" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" paych7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/paych" adt7 "github.com/filecoin-project/specs-actors/v7/actors/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -111,3 +115,20 @@ func (ls *laneState7) Redeemed() (big.Int, error) { func (ls *laneState7) Nonce() (uint64, error) { return ls.LaneState.Nonce, nil } + +func (s *state7) ActorKey() string { + return actors.PaychKey +} + +func (s *state7) ActorVersion() actorstypes.Version { + return actorstypes.Version7 +} + +func (s *state7) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/paych/v8.go b/chain/actors/builtin/paych/v8.go index 1961e69ec..fc6853cad 100644 --- a/chain/actors/builtin/paych/v8.go +++ b/chain/actors/builtin/paych/v8.go @@ -1,14 +1,18 @@ package paych import ( + "fmt" + "github.com/ipfs/go-cid" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" paych8 "github.com/filecoin-project/go-state-types/builtin/v8/paych" adt8 "github.com/filecoin-project/go-state-types/builtin/v8/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -111,3 +115,20 @@ func (ls *laneState8) Redeemed() (big.Int, error) { func (ls *laneState8) Nonce() (uint64, error) { return ls.LaneState.Nonce, nil } + +func (s *state8) ActorKey() string { + return actors.PaychKey +} + +func (s *state8) ActorVersion() actorstypes.Version { + return actorstypes.Version8 +} + +func (s *state8) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/paych/v9.go b/chain/actors/builtin/paych/v9.go index 443fe74ea..817541dfb 100644 --- a/chain/actors/builtin/paych/v9.go +++ b/chain/actors/builtin/paych/v9.go @@ -1,14 +1,18 @@ package paych import ( + "fmt" + "github.com/ipfs/go-cid" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" paych9 "github.com/filecoin-project/go-state-types/builtin/v9/paych" adt9 "github.com/filecoin-project/go-state-types/builtin/v9/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -111,3 +115,20 @@ func (ls *laneState9) Redeemed() (big.Int, error) { func (ls *laneState9) Nonce() (uint64, error) { return ls.LaneState.Nonce, nil } + +func (s *state9) ActorKey() string { + return actors.PaychKey +} + +func (s *state9) ActorVersion() actorstypes.Version { + return actorstypes.Version9 +} + +func (s *state9) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/power/actor.go.template b/chain/actors/builtin/power/actor.go.template index 93fe70370..0a4d70f46 100644 --- a/chain/actors/builtin/power/actor.go.template +++ b/chain/actors/builtin/power/actor.go.template @@ -1,6 +1,7 @@ package power import ( + "github.com/ipfs/go-cid" actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/big" @@ -69,6 +70,10 @@ func MakeState(store adt.Store, av actorstypes.Version) (State, error) { type State interface { cbor.Marshaler + Code() cid.Cid + ActorKey() string + ActorVersion() actorstypes.Version + TotalLocked() (abi.TokenAmount, error) TotalPower() (Claim, error) TotalCommitted() (Claim, error) @@ -109,3 +114,10 @@ func AddClaims(a Claim, b Claim) Claim { QualityAdjPower: big.Add(a.QualityAdjPower, b.QualityAdjPower), } } + +func AllCodes() []cid.Cid { + return []cid.Cid{ {{range .versions}} + (&state{{.}}{}).Code(), + {{- end}} + } +} diff --git a/chain/actors/builtin/power/power.go b/chain/actors/builtin/power/power.go index dc008f1f1..050335d6e 100644 --- a/chain/actors/builtin/power/power.go +++ b/chain/actors/builtin/power/power.go @@ -1,6 +1,7 @@ package power import ( + "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" @@ -111,6 +112,10 @@ func MakeState(store adt.Store, av actorstypes.Version) (State, error) { type State interface { cbor.Marshaler + Code() cid.Cid + ActorKey() string + ActorVersion() actorstypes.Version + TotalLocked() (abi.TokenAmount, error) TotalPower() (Claim, error) TotalCommitted() (Claim, error) @@ -151,3 +156,17 @@ func AddClaims(a Claim, b Claim) Claim { QualityAdjPower: big.Add(a.QualityAdjPower, b.QualityAdjPower), } } + +func AllCodes() []cid.Cid { + return []cid.Cid{ + (&state0{}).Code(), + (&state2{}).Code(), + (&state3{}).Code(), + (&state4{}).Code(), + (&state5{}).Code(), + (&state6{}).Code(), + (&state7{}).Code(), + (&state8{}).Code(), + (&state9{}).Code(), + } +} diff --git a/chain/actors/builtin/power/state.go.template b/chain/actors/builtin/power/state.go.template index 08362d2db..8c2a8ce97 100644 --- a/chain/actors/builtin/power/state.go.template +++ b/chain/actors/builtin/power/state.go.template @@ -1,6 +1,8 @@ package power import ( + "fmt" + actorstypes "github.com/filecoin-project/go-state-types/actors" "bytes" "github.com/filecoin-project/go-address" @@ -8,6 +10,7 @@ import ( "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors/builtin" @@ -205,3 +208,20 @@ func fromV{{.v}}Claim(v{{.v}} power{{.v}}.Claim) Claim { QualityAdjPower: v{{.v}}.QualityAdjPower, } } + +func (s *state{{.v}}) ActorKey() string { + return actors.PowerKey +} + +func (s *state{{.v}}) ActorVersion() actorstypes.Version { + return actorstypes.Version{{.v}} +} + +func (s *state{{.v}}) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/power/v0.go b/chain/actors/builtin/power/v0.go index 5ae42b4df..56982e77b 100644 --- a/chain/actors/builtin/power/v0.go +++ b/chain/actors/builtin/power/v0.go @@ -2,15 +2,18 @@ package power import ( "bytes" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" power0 "github.com/filecoin-project/specs-actors/actors/builtin/power" adt0 "github.com/filecoin-project/specs-actors/actors/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors/builtin" ) @@ -188,3 +191,20 @@ func fromV0Claim(v0 power0.Claim) Claim { QualityAdjPower: v0.QualityAdjPower, } } + +func (s *state0) ActorKey() string { + return actors.PowerKey +} + +func (s *state0) ActorVersion() actorstypes.Version { + return actorstypes.Version0 +} + +func (s *state0) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/power/v2.go b/chain/actors/builtin/power/v2.go index 485819e3e..b4e253024 100644 --- a/chain/actors/builtin/power/v2.go +++ b/chain/actors/builtin/power/v2.go @@ -2,15 +2,18 @@ package power import ( "bytes" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" power2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/power" adt2 "github.com/filecoin-project/specs-actors/v2/actors/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors/builtin" ) @@ -188,3 +191,20 @@ func fromV2Claim(v2 power2.Claim) Claim { QualityAdjPower: v2.QualityAdjPower, } } + +func (s *state2) ActorKey() string { + return actors.PowerKey +} + +func (s *state2) ActorVersion() actorstypes.Version { + return actorstypes.Version2 +} + +func (s *state2) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/power/v3.go b/chain/actors/builtin/power/v3.go index e33ee2bb5..2b2b75ae7 100644 --- a/chain/actors/builtin/power/v3.go +++ b/chain/actors/builtin/power/v3.go @@ -2,16 +2,19 @@ package power import ( "bytes" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin" power3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/power" adt3 "github.com/filecoin-project/specs-actors/v3/actors/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors/builtin" ) @@ -184,3 +187,20 @@ func fromV3Claim(v3 power3.Claim) Claim { QualityAdjPower: v3.QualityAdjPower, } } + +func (s *state3) ActorKey() string { + return actors.PowerKey +} + +func (s *state3) ActorVersion() actorstypes.Version { + return actorstypes.Version3 +} + +func (s *state3) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/power/v4.go b/chain/actors/builtin/power/v4.go index e5c446f07..c40dad92a 100644 --- a/chain/actors/builtin/power/v4.go +++ b/chain/actors/builtin/power/v4.go @@ -2,16 +2,19 @@ package power import ( "bytes" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin" power4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/power" adt4 "github.com/filecoin-project/specs-actors/v4/actors/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors/builtin" ) @@ -184,3 +187,20 @@ func fromV4Claim(v4 power4.Claim) Claim { QualityAdjPower: v4.QualityAdjPower, } } + +func (s *state4) ActorKey() string { + return actors.PowerKey +} + +func (s *state4) ActorVersion() actorstypes.Version { + return actorstypes.Version4 +} + +func (s *state4) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/power/v5.go b/chain/actors/builtin/power/v5.go index aaf248058..5d740a40b 100644 --- a/chain/actors/builtin/power/v5.go +++ b/chain/actors/builtin/power/v5.go @@ -2,16 +2,19 @@ package power import ( "bytes" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin" power5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/power" adt5 "github.com/filecoin-project/specs-actors/v5/actors/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors/builtin" ) @@ -184,3 +187,20 @@ func fromV5Claim(v5 power5.Claim) Claim { QualityAdjPower: v5.QualityAdjPower, } } + +func (s *state5) ActorKey() string { + return actors.PowerKey +} + +func (s *state5) ActorVersion() actorstypes.Version { + return actorstypes.Version5 +} + +func (s *state5) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/power/v6.go b/chain/actors/builtin/power/v6.go index 072def6e2..45c0db9e8 100644 --- a/chain/actors/builtin/power/v6.go +++ b/chain/actors/builtin/power/v6.go @@ -2,16 +2,19 @@ package power import ( "bytes" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin" power6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/power" adt6 "github.com/filecoin-project/specs-actors/v6/actors/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors/builtin" ) @@ -184,3 +187,20 @@ func fromV6Claim(v6 power6.Claim) Claim { QualityAdjPower: v6.QualityAdjPower, } } + +func (s *state6) ActorKey() string { + return actors.PowerKey +} + +func (s *state6) ActorVersion() actorstypes.Version { + return actorstypes.Version6 +} + +func (s *state6) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/power/v7.go b/chain/actors/builtin/power/v7.go index 0c60b03a0..314318263 100644 --- a/chain/actors/builtin/power/v7.go +++ b/chain/actors/builtin/power/v7.go @@ -2,16 +2,19 @@ package power import ( "bytes" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" power7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/power" adt7 "github.com/filecoin-project/specs-actors/v7/actors/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors/builtin" ) @@ -184,3 +187,20 @@ func fromV7Claim(v7 power7.Claim) Claim { QualityAdjPower: v7.QualityAdjPower, } } + +func (s *state7) ActorKey() string { + return actors.PowerKey +} + +func (s *state7) ActorVersion() actorstypes.Version { + return actorstypes.Version7 +} + +func (s *state7) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/power/v8.go b/chain/actors/builtin/power/v8.go index c23da6904..a462b2600 100644 --- a/chain/actors/builtin/power/v8.go +++ b/chain/actors/builtin/power/v8.go @@ -2,16 +2,19 @@ package power import ( "bytes" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" builtin8 "github.com/filecoin-project/go-state-types/builtin" power8 "github.com/filecoin-project/go-state-types/builtin/v8/power" adt8 "github.com/filecoin-project/go-state-types/builtin/v8/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors/builtin" ) @@ -184,3 +187,20 @@ func fromV8Claim(v8 power8.Claim) Claim { QualityAdjPower: v8.QualityAdjPower, } } + +func (s *state8) ActorKey() string { + return actors.PowerKey +} + +func (s *state8) ActorVersion() actorstypes.Version { + return actorstypes.Version8 +} + +func (s *state8) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/power/v9.go b/chain/actors/builtin/power/v9.go index 7614b7c2e..0e8d5b072 100644 --- a/chain/actors/builtin/power/v9.go +++ b/chain/actors/builtin/power/v9.go @@ -2,16 +2,19 @@ package power import ( "bytes" + "fmt" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" builtin9 "github.com/filecoin-project/go-state-types/builtin" power9 "github.com/filecoin-project/go-state-types/builtin/v9/power" adt9 "github.com/filecoin-project/go-state-types/builtin/v9/util/adt" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors/builtin" ) @@ -184,3 +187,20 @@ func fromV9Claim(v9 power9.Claim) Claim { QualityAdjPower: v9.QualityAdjPower, } } + +func (s *state9) ActorKey() string { + return actors.PowerKey +} + +func (s *state9) ActorVersion() actorstypes.Version { + return actorstypes.Version9 +} + +func (s *state9) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/reward/actor.go.template b/chain/actors/builtin/reward/actor.go.template index 165f9efdf..4fd317c97 100644 --- a/chain/actors/builtin/reward/actor.go.template +++ b/chain/actors/builtin/reward/actor.go.template @@ -1,6 +1,7 @@ package reward import ( + "github.com/ipfs/go-cid" actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/abi" reward0 "github.com/filecoin-project/specs-actors/actors/builtin/reward" @@ -66,6 +67,10 @@ func MakeState(store adt.Store, av actorstypes.Version, currRealizedPower abi.St type State interface { cbor.Marshaler + Code() cid.Cid + ActorKey() string + ActorVersion() actorstypes.Version + ThisEpochBaselinePower() (abi.StoragePower, error) ThisEpochReward() (abi.StoragePower, error) ThisEpochRewardSmoothed() (builtin.FilterEstimate, error) @@ -84,3 +89,10 @@ type State interface { } type AwardBlockRewardParams = reward0.AwardBlockRewardParams + +func AllCodes() []cid.Cid { + return []cid.Cid{ {{range .versions}} + (&state{{.}}{}).Code(), + {{- end}} + } +} diff --git a/chain/actors/builtin/reward/reward.go b/chain/actors/builtin/reward/reward.go index 6902b258e..f91779aa4 100644 --- a/chain/actors/builtin/reward/reward.go +++ b/chain/actors/builtin/reward/reward.go @@ -1,6 +1,7 @@ package reward import ( + "github.com/ipfs/go-cid" "golang.org/x/xerrors" "github.com/filecoin-project/go-state-types/abi" @@ -109,6 +110,10 @@ func MakeState(store adt.Store, av actorstypes.Version, currRealizedPower abi.St type State interface { cbor.Marshaler + Code() cid.Cid + ActorKey() string + ActorVersion() actorstypes.Version + ThisEpochBaselinePower() (abi.StoragePower, error) ThisEpochReward() (abi.StoragePower, error) ThisEpochRewardSmoothed() (builtin.FilterEstimate, error) @@ -127,3 +132,17 @@ type State interface { } type AwardBlockRewardParams = reward0.AwardBlockRewardParams + +func AllCodes() []cid.Cid { + return []cid.Cid{ + (&state0{}).Code(), + (&state2{}).Code(), + (&state3{}).Code(), + (&state4{}).Code(), + (&state5{}).Code(), + (&state6{}).Code(), + (&state7{}).Code(), + (&state8{}).Code(), + (&state9{}).Code(), + } +} diff --git a/chain/actors/builtin/reward/state.go.template b/chain/actors/builtin/reward/state.go.template index dac3d82a4..104aefbaf 100644 --- a/chain/actors/builtin/reward/state.go.template +++ b/chain/actors/builtin/reward/state.go.template @@ -1,9 +1,12 @@ package reward import ( + "fmt" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/abi" "github.com/ipfs/go-cid" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors/builtin" @@ -117,3 +120,20 @@ func (s *state{{.v}}) PreCommitDepositForPower(networkQAPower builtin.FilterEsti func (s *state{{.v}}) GetState() interface{} { return &s.State } + +func (s *state{{.v}}) ActorKey() string { + return actors.RewardKey +} + +func (s *state{{.v}}) ActorVersion() actorstypes.Version { + return actorstypes.Version{{.v}} +} + +func (s *state{{.v}}) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/reward/v0.go b/chain/actors/builtin/reward/v0.go index 12bdee054..332e97128 100644 --- a/chain/actors/builtin/reward/v0.go +++ b/chain/actors/builtin/reward/v0.go @@ -1,13 +1,17 @@ package reward import ( + "fmt" + "github.com/ipfs/go-cid" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner" reward0 "github.com/filecoin-project/specs-actors/actors/builtin/reward" smoothing0 "github.com/filecoin-project/specs-actors/actors/util/smoothing" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors/builtin" ) @@ -93,3 +97,20 @@ func (s *state0) PreCommitDepositForPower(networkQAPower builtin.FilterEstimate, func (s *state0) GetState() interface{} { return &s.State } + +func (s *state0) ActorKey() string { + return actors.RewardKey +} + +func (s *state0) ActorVersion() actorstypes.Version { + return actorstypes.Version0 +} + +func (s *state0) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/reward/v2.go b/chain/actors/builtin/reward/v2.go index ed2481635..33f6c120f 100644 --- a/chain/actors/builtin/reward/v2.go +++ b/chain/actors/builtin/reward/v2.go @@ -1,13 +1,17 @@ package reward import ( + "fmt" + "github.com/ipfs/go-cid" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner" reward2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/reward" smoothing2 "github.com/filecoin-project/specs-actors/v2/actors/util/smoothing" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors/builtin" ) @@ -96,3 +100,20 @@ func (s *state2) PreCommitDepositForPower(networkQAPower builtin.FilterEstimate, func (s *state2) GetState() interface{} { return &s.State } + +func (s *state2) ActorKey() string { + return actors.RewardKey +} + +func (s *state2) ActorVersion() actorstypes.Version { + return actorstypes.Version2 +} + +func (s *state2) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/reward/v3.go b/chain/actors/builtin/reward/v3.go index d9f4bf369..d727a9861 100644 --- a/chain/actors/builtin/reward/v3.go +++ b/chain/actors/builtin/reward/v3.go @@ -1,13 +1,17 @@ package reward import ( + "fmt" + "github.com/ipfs/go-cid" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" miner3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/miner" reward3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/reward" smoothing3 "github.com/filecoin-project/specs-actors/v3/actors/util/smoothing" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors/builtin" ) @@ -96,3 +100,20 @@ func (s *state3) PreCommitDepositForPower(networkQAPower builtin.FilterEstimate, func (s *state3) GetState() interface{} { return &s.State } + +func (s *state3) ActorKey() string { + return actors.RewardKey +} + +func (s *state3) ActorVersion() actorstypes.Version { + return actorstypes.Version3 +} + +func (s *state3) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/reward/v4.go b/chain/actors/builtin/reward/v4.go index 160c72ce7..94ebc43c4 100644 --- a/chain/actors/builtin/reward/v4.go +++ b/chain/actors/builtin/reward/v4.go @@ -1,13 +1,17 @@ package reward import ( + "fmt" + "github.com/ipfs/go-cid" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" miner4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/miner" reward4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/reward" smoothing4 "github.com/filecoin-project/specs-actors/v4/actors/util/smoothing" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors/builtin" ) @@ -96,3 +100,20 @@ func (s *state4) PreCommitDepositForPower(networkQAPower builtin.FilterEstimate, func (s *state4) GetState() interface{} { return &s.State } + +func (s *state4) ActorKey() string { + return actors.RewardKey +} + +func (s *state4) ActorVersion() actorstypes.Version { + return actorstypes.Version4 +} + +func (s *state4) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/reward/v5.go b/chain/actors/builtin/reward/v5.go index 838ec8f21..563b8f42a 100644 --- a/chain/actors/builtin/reward/v5.go +++ b/chain/actors/builtin/reward/v5.go @@ -1,13 +1,17 @@ package reward import ( + "fmt" + "github.com/ipfs/go-cid" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" miner5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/miner" reward5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/reward" smoothing5 "github.com/filecoin-project/specs-actors/v5/actors/util/smoothing" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors/builtin" ) @@ -96,3 +100,20 @@ func (s *state5) PreCommitDepositForPower(networkQAPower builtin.FilterEstimate, func (s *state5) GetState() interface{} { return &s.State } + +func (s *state5) ActorKey() string { + return actors.RewardKey +} + +func (s *state5) ActorVersion() actorstypes.Version { + return actorstypes.Version5 +} + +func (s *state5) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/reward/v6.go b/chain/actors/builtin/reward/v6.go index e056b22f6..523736766 100644 --- a/chain/actors/builtin/reward/v6.go +++ b/chain/actors/builtin/reward/v6.go @@ -1,13 +1,17 @@ package reward import ( + "fmt" + "github.com/ipfs/go-cid" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" miner6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/miner" reward6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/reward" smoothing6 "github.com/filecoin-project/specs-actors/v6/actors/util/smoothing" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors/builtin" ) @@ -96,3 +100,20 @@ func (s *state6) PreCommitDepositForPower(networkQAPower builtin.FilterEstimate, func (s *state6) GetState() interface{} { return &s.State } + +func (s *state6) ActorKey() string { + return actors.RewardKey +} + +func (s *state6) ActorVersion() actorstypes.Version { + return actorstypes.Version6 +} + +func (s *state6) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/reward/v7.go b/chain/actors/builtin/reward/v7.go index 5fedaa43c..79db860e1 100644 --- a/chain/actors/builtin/reward/v7.go +++ b/chain/actors/builtin/reward/v7.go @@ -1,13 +1,17 @@ package reward import ( + "fmt" + "github.com/ipfs/go-cid" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" miner7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/miner" reward7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/reward" smoothing7 "github.com/filecoin-project/specs-actors/v7/actors/util/smoothing" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors/builtin" ) @@ -96,3 +100,20 @@ func (s *state7) PreCommitDepositForPower(networkQAPower builtin.FilterEstimate, func (s *state7) GetState() interface{} { return &s.State } + +func (s *state7) ActorKey() string { + return actors.RewardKey +} + +func (s *state7) ActorVersion() actorstypes.Version { + return actorstypes.Version7 +} + +func (s *state7) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/reward/v8.go b/chain/actors/builtin/reward/v8.go index ecc5a94ba..a9d6fae69 100644 --- a/chain/actors/builtin/reward/v8.go +++ b/chain/actors/builtin/reward/v8.go @@ -1,13 +1,17 @@ package reward import ( + "fmt" + "github.com/ipfs/go-cid" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" miner8 "github.com/filecoin-project/go-state-types/builtin/v8/miner" reward8 "github.com/filecoin-project/go-state-types/builtin/v8/reward" smoothing8 "github.com/filecoin-project/go-state-types/builtin/v8/util/smoothing" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors/builtin" ) @@ -96,3 +100,20 @@ func (s *state8) PreCommitDepositForPower(networkQAPower builtin.FilterEstimate, func (s *state8) GetState() interface{} { return &s.State } + +func (s *state8) ActorKey() string { + return actors.RewardKey +} + +func (s *state8) ActorVersion() actorstypes.Version { + return actorstypes.Version8 +} + +func (s *state8) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/reward/v9.go b/chain/actors/builtin/reward/v9.go index 04da532d2..34b8a7d34 100644 --- a/chain/actors/builtin/reward/v9.go +++ b/chain/actors/builtin/reward/v9.go @@ -1,13 +1,17 @@ package reward import ( + "fmt" + "github.com/ipfs/go-cid" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" miner9 "github.com/filecoin-project/go-state-types/builtin/v9/miner" reward9 "github.com/filecoin-project/go-state-types/builtin/v9/reward" smoothing9 "github.com/filecoin-project/go-state-types/builtin/v9/util/smoothing" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors/builtin" ) @@ -96,3 +100,20 @@ func (s *state9) PreCommitDepositForPower(networkQAPower builtin.FilterEstimate, func (s *state9) GetState() interface{} { return &s.State } + +func (s *state9) ActorKey() string { + return actors.RewardKey +} + +func (s *state9) ActorVersion() actorstypes.Version { + return actorstypes.Version9 +} + +func (s *state9) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/system/actor.go.template b/chain/actors/builtin/system/actor.go.template index 0ef41e775..a6442c6a9 100644 --- a/chain/actors/builtin/system/actor.go.template +++ b/chain/actors/builtin/system/actor.go.template @@ -1,6 +1,7 @@ package system import ( + "github.com/ipfs/go-cid" actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors" @@ -60,7 +61,18 @@ func MakeState(store adt.Store, av actorstypes.Version, builtinActors cid.Cid) ( } type State interface { + Code() cid.Cid + ActorKey() string + ActorVersion() actorstypes.Version + GetState() interface{} GetBuiltinActors() cid.Cid SetBuiltinActors(cid.Cid) error } + +func AllCodes() []cid.Cid { + return []cid.Cid{ {{range .versions}} + (&state{{.}}{}).Code(), + {{- end}} + } +} diff --git a/chain/actors/builtin/system/state.go.template b/chain/actors/builtin/system/state.go.template index f8d9addf7..62dba041a 100644 --- a/chain/actors/builtin/system/state.go.template +++ b/chain/actors/builtin/system/state.go.template @@ -1,9 +1,13 @@ package system import ( + "fmt" + actorstypes "github.com/filecoin-project/go-state-types/actors" + "github.com/ipfs/go-cid" "github.com/filecoin-project/lotus/chain/actors/adt" + "github.com/filecoin-project/lotus/chain/actors" {{if (le .v 7)}} system{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/system" @@ -56,4 +60,21 @@ func (s *state{{.v}}) SetBuiltinActors(c cid.Cid) error { s.State.BuiltinActors = c return nil {{end}} -} \ No newline at end of file +} + +func (s *state{{.v}}) ActorKey() string { + return actors.SystemKey +} + +func (s *state{{.v}}) ActorVersion() actorstypes.Version { + return actorstypes.Version{{.v}} +} + +func (s *state{{.v}}) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/system/system.go b/chain/actors/builtin/system/system.go index 4c99d90eb..a6daa6ce7 100644 --- a/chain/actors/builtin/system/system.go +++ b/chain/actors/builtin/system/system.go @@ -103,7 +103,25 @@ func MakeState(store adt.Store, av actorstypes.Version, builtinActors cid.Cid) ( } type State interface { + Code() cid.Cid + ActorKey() string + ActorVersion() actorstypes.Version + GetState() interface{} GetBuiltinActors() cid.Cid SetBuiltinActors(cid.Cid) error } + +func AllCodes() []cid.Cid { + return []cid.Cid{ + (&state0{}).Code(), + (&state2{}).Code(), + (&state3{}).Code(), + (&state4{}).Code(), + (&state5{}).Code(), + (&state6{}).Code(), + (&state7{}).Code(), + (&state8{}).Code(), + (&state9{}).Code(), + } +} diff --git a/chain/actors/builtin/system/v0.go b/chain/actors/builtin/system/v0.go index 78e578896..17fa9e8c7 100644 --- a/chain/actors/builtin/system/v0.go +++ b/chain/actors/builtin/system/v0.go @@ -1,11 +1,15 @@ package system import ( + "fmt" + "github.com/ipfs/go-cid" "golang.org/x/xerrors" + actorstypes "github.com/filecoin-project/go-state-types/actors" system0 "github.com/filecoin-project/specs-actors/actors/builtin/system" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -46,3 +50,20 @@ func (s *state0) SetBuiltinActors(c cid.Cid) error { return xerrors.New("cannot set manifest cid before v8") } + +func (s *state0) ActorKey() string { + return actors.SystemKey +} + +func (s *state0) ActorVersion() actorstypes.Version { + return actorstypes.Version0 +} + +func (s *state0) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/system/v2.go b/chain/actors/builtin/system/v2.go index 21dfa5c78..7821bee58 100644 --- a/chain/actors/builtin/system/v2.go +++ b/chain/actors/builtin/system/v2.go @@ -1,11 +1,15 @@ package system import ( + "fmt" + "github.com/ipfs/go-cid" "golang.org/x/xerrors" + actorstypes "github.com/filecoin-project/go-state-types/actors" system2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/system" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -46,3 +50,20 @@ func (s *state2) SetBuiltinActors(c cid.Cid) error { return xerrors.New("cannot set manifest cid before v8") } + +func (s *state2) ActorKey() string { + return actors.SystemKey +} + +func (s *state2) ActorVersion() actorstypes.Version { + return actorstypes.Version2 +} + +func (s *state2) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/system/v3.go b/chain/actors/builtin/system/v3.go index ccf8aa2c3..0c80218c4 100644 --- a/chain/actors/builtin/system/v3.go +++ b/chain/actors/builtin/system/v3.go @@ -1,11 +1,15 @@ package system import ( + "fmt" + "github.com/ipfs/go-cid" "golang.org/x/xerrors" + actorstypes "github.com/filecoin-project/go-state-types/actors" system3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/system" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -46,3 +50,20 @@ func (s *state3) SetBuiltinActors(c cid.Cid) error { return xerrors.New("cannot set manifest cid before v8") } + +func (s *state3) ActorKey() string { + return actors.SystemKey +} + +func (s *state3) ActorVersion() actorstypes.Version { + return actorstypes.Version3 +} + +func (s *state3) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/system/v4.go b/chain/actors/builtin/system/v4.go index bcb120be2..e41792110 100644 --- a/chain/actors/builtin/system/v4.go +++ b/chain/actors/builtin/system/v4.go @@ -1,11 +1,15 @@ package system import ( + "fmt" + "github.com/ipfs/go-cid" "golang.org/x/xerrors" + actorstypes "github.com/filecoin-project/go-state-types/actors" system4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/system" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -46,3 +50,20 @@ func (s *state4) SetBuiltinActors(c cid.Cid) error { return xerrors.New("cannot set manifest cid before v8") } + +func (s *state4) ActorKey() string { + return actors.SystemKey +} + +func (s *state4) ActorVersion() actorstypes.Version { + return actorstypes.Version4 +} + +func (s *state4) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/system/v5.go b/chain/actors/builtin/system/v5.go index 182883398..a2760b096 100644 --- a/chain/actors/builtin/system/v5.go +++ b/chain/actors/builtin/system/v5.go @@ -1,11 +1,15 @@ package system import ( + "fmt" + "github.com/ipfs/go-cid" "golang.org/x/xerrors" + actorstypes "github.com/filecoin-project/go-state-types/actors" system5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/system" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -46,3 +50,20 @@ func (s *state5) SetBuiltinActors(c cid.Cid) error { return xerrors.New("cannot set manifest cid before v8") } + +func (s *state5) ActorKey() string { + return actors.SystemKey +} + +func (s *state5) ActorVersion() actorstypes.Version { + return actorstypes.Version5 +} + +func (s *state5) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/system/v6.go b/chain/actors/builtin/system/v6.go index 9860ce373..0de085a5e 100644 --- a/chain/actors/builtin/system/v6.go +++ b/chain/actors/builtin/system/v6.go @@ -1,11 +1,15 @@ package system import ( + "fmt" + "github.com/ipfs/go-cid" "golang.org/x/xerrors" + actorstypes "github.com/filecoin-project/go-state-types/actors" system6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/system" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -46,3 +50,20 @@ func (s *state6) SetBuiltinActors(c cid.Cid) error { return xerrors.New("cannot set manifest cid before v8") } + +func (s *state6) ActorKey() string { + return actors.SystemKey +} + +func (s *state6) ActorVersion() actorstypes.Version { + return actorstypes.Version6 +} + +func (s *state6) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/system/v7.go b/chain/actors/builtin/system/v7.go index 5984b0b4d..2753251c0 100644 --- a/chain/actors/builtin/system/v7.go +++ b/chain/actors/builtin/system/v7.go @@ -1,11 +1,15 @@ package system import ( + "fmt" + "github.com/ipfs/go-cid" "golang.org/x/xerrors" + actorstypes "github.com/filecoin-project/go-state-types/actors" system7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/system" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -46,3 +50,20 @@ func (s *state7) SetBuiltinActors(c cid.Cid) error { return xerrors.New("cannot set manifest cid before v8") } + +func (s *state7) ActorKey() string { + return actors.SystemKey +} + +func (s *state7) ActorVersion() actorstypes.Version { + return actorstypes.Version7 +} + +func (s *state7) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/system/v8.go b/chain/actors/builtin/system/v8.go index 574df9c44..00cafdfed 100644 --- a/chain/actors/builtin/system/v8.go +++ b/chain/actors/builtin/system/v8.go @@ -1,10 +1,14 @@ package system import ( + "fmt" + "github.com/ipfs/go-cid" + actorstypes "github.com/filecoin-project/go-state-types/actors" system8 "github.com/filecoin-project/go-state-types/builtin/v8/system" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -48,3 +52,20 @@ func (s *state8) SetBuiltinActors(c cid.Cid) error { return nil } + +func (s *state8) ActorKey() string { + return actors.SystemKey +} + +func (s *state8) ActorVersion() actorstypes.Version { + return actorstypes.Version8 +} + +func (s *state8) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/system/v9.go b/chain/actors/builtin/system/v9.go index 40555a921..8bf96a917 100644 --- a/chain/actors/builtin/system/v9.go +++ b/chain/actors/builtin/system/v9.go @@ -1,10 +1,14 @@ package system import ( + "fmt" + "github.com/ipfs/go-cid" + actorstypes "github.com/filecoin-project/go-state-types/actors" system9 "github.com/filecoin-project/go-state-types/builtin/v9/system" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -48,3 +52,20 @@ func (s *state9) SetBuiltinActors(c cid.Cid) error { return nil } + +func (s *state9) ActorKey() string { + return actors.SystemKey +} + +func (s *state9) ActorVersion() actorstypes.Version { + return actorstypes.Version9 +} + +func (s *state9) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/verifreg/actor.go.template b/chain/actors/builtin/verifreg/actor.go.template index 5c7715e3d..fe8eb1849 100644 --- a/chain/actors/builtin/verifreg/actor.go.template +++ b/chain/actors/builtin/verifreg/actor.go.template @@ -1,6 +1,7 @@ package verifreg import ( + "github.com/ipfs/go-cid" actorstypes "github.com/filecoin-project/go-state-types/actors" "golang.org/x/xerrors" @@ -67,6 +68,10 @@ func MakeState(store adt.Store, av actorstypes.Version, rootKeyAddress address.A type State interface { cbor.Marshaler + Code() cid.Cid + ActorKey() string + ActorVersion() actorstypes.Version + RootKey() (address.Address, error) VerifiedClientDataCap(address.Address) (bool, abi.StoragePower, error) VerifierDataCap(address.Address) (bool, abi.StoragePower, error) @@ -79,3 +84,10 @@ type State interface { GetClaims(providerIdAddr address.Address) (map[verifregtypes.ClaimId]verifregtypes.Claim, error) GetState() interface{} } + +func AllCodes() []cid.Cid { + return []cid.Cid{ {{range .versions}} + (&state{{.}}{}).Code(), + {{- end}} + } +} diff --git a/chain/actors/builtin/verifreg/state.go.template b/chain/actors/builtin/verifreg/state.go.template index cc3c2a781..70aaf3b6e 100644 --- a/chain/actors/builtin/verifreg/state.go.template +++ b/chain/actors/builtin/verifreg/state.go.template @@ -1,6 +1,8 @@ package verifreg import ( + "fmt" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/ipfs/go-cid" @@ -147,3 +149,20 @@ func (s *state{{.v}}) GetClaims(providerIdAddr address.Address) (map[verifreg9.C return s.LoadClaimsToMap(s.store, providerIdAddr) {{end}} } + +func (s *state{{.v}}) ActorKey() string { + return actors.VerifregKey +} + +func (s *state{{.v}}) ActorVersion() actorstypes.Version { + return actorstypes.Version{{.v}} +} + +func (s *state{{.v}}) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/verifreg/v0.go b/chain/actors/builtin/verifreg/v0.go index debe32125..d8d81b4d3 100644 --- a/chain/actors/builtin/verifreg/v0.go +++ b/chain/actors/builtin/verifreg/v0.go @@ -1,11 +1,14 @@ package verifreg import ( + "fmt" + "github.com/ipfs/go-cid" "golang.org/x/xerrors" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" verifreg9 "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" verifreg0 "github.com/filecoin-project/specs-actors/actors/builtin/verifreg" adt0 "github.com/filecoin-project/specs-actors/actors/util/adt" @@ -113,3 +116,20 @@ func (s *state0) GetClaims(providerIdAddr address.Address) (map[verifreg9.ClaimI return nil, xerrors.Errorf("unsupported in actors v0") } + +func (s *state0) ActorKey() string { + return actors.VerifregKey +} + +func (s *state0) ActorVersion() actorstypes.Version { + return actorstypes.Version0 +} + +func (s *state0) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/verifreg/v2.go b/chain/actors/builtin/verifreg/v2.go index a6f07eea2..c12e3a505 100644 --- a/chain/actors/builtin/verifreg/v2.go +++ b/chain/actors/builtin/verifreg/v2.go @@ -1,11 +1,14 @@ package verifreg import ( + "fmt" + "github.com/ipfs/go-cid" "golang.org/x/xerrors" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" verifreg9 "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" verifreg2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/verifreg" adt2 "github.com/filecoin-project/specs-actors/v2/actors/util/adt" @@ -113,3 +116,20 @@ func (s *state2) GetClaims(providerIdAddr address.Address) (map[verifreg9.ClaimI return nil, xerrors.Errorf("unsupported in actors v2") } + +func (s *state2) ActorKey() string { + return actors.VerifregKey +} + +func (s *state2) ActorVersion() actorstypes.Version { + return actorstypes.Version2 +} + +func (s *state2) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/verifreg/v3.go b/chain/actors/builtin/verifreg/v3.go index 11e56d8ae..3ac18aa6d 100644 --- a/chain/actors/builtin/verifreg/v3.go +++ b/chain/actors/builtin/verifreg/v3.go @@ -1,11 +1,14 @@ package verifreg import ( + "fmt" + "github.com/ipfs/go-cid" "golang.org/x/xerrors" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" verifreg9 "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin" verifreg3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/verifreg" @@ -114,3 +117,20 @@ func (s *state3) GetClaims(providerIdAddr address.Address) (map[verifreg9.ClaimI return nil, xerrors.Errorf("unsupported in actors v3") } + +func (s *state3) ActorKey() string { + return actors.VerifregKey +} + +func (s *state3) ActorVersion() actorstypes.Version { + return actorstypes.Version3 +} + +func (s *state3) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/verifreg/v4.go b/chain/actors/builtin/verifreg/v4.go index da51e78b8..c99e84478 100644 --- a/chain/actors/builtin/verifreg/v4.go +++ b/chain/actors/builtin/verifreg/v4.go @@ -1,11 +1,14 @@ package verifreg import ( + "fmt" + "github.com/ipfs/go-cid" "golang.org/x/xerrors" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" verifreg9 "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin" verifreg4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/verifreg" @@ -114,3 +117,20 @@ func (s *state4) GetClaims(providerIdAddr address.Address) (map[verifreg9.ClaimI return nil, xerrors.Errorf("unsupported in actors v4") } + +func (s *state4) ActorKey() string { + return actors.VerifregKey +} + +func (s *state4) ActorVersion() actorstypes.Version { + return actorstypes.Version4 +} + +func (s *state4) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/verifreg/v5.go b/chain/actors/builtin/verifreg/v5.go index 08f8ad706..45e416693 100644 --- a/chain/actors/builtin/verifreg/v5.go +++ b/chain/actors/builtin/verifreg/v5.go @@ -1,11 +1,14 @@ package verifreg import ( + "fmt" + "github.com/ipfs/go-cid" "golang.org/x/xerrors" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" verifreg9 "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin" verifreg5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/verifreg" @@ -114,3 +117,20 @@ func (s *state5) GetClaims(providerIdAddr address.Address) (map[verifreg9.ClaimI return nil, xerrors.Errorf("unsupported in actors v5") } + +func (s *state5) ActorKey() string { + return actors.VerifregKey +} + +func (s *state5) ActorVersion() actorstypes.Version { + return actorstypes.Version5 +} + +func (s *state5) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/verifreg/v6.go b/chain/actors/builtin/verifreg/v6.go index 8e6fc3603..d181366dc 100644 --- a/chain/actors/builtin/verifreg/v6.go +++ b/chain/actors/builtin/verifreg/v6.go @@ -1,11 +1,14 @@ package verifreg import ( + "fmt" + "github.com/ipfs/go-cid" "golang.org/x/xerrors" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" verifreg9 "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin" verifreg6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/verifreg" @@ -114,3 +117,20 @@ func (s *state6) GetClaims(providerIdAddr address.Address) (map[verifreg9.ClaimI return nil, xerrors.Errorf("unsupported in actors v6") } + +func (s *state6) ActorKey() string { + return actors.VerifregKey +} + +func (s *state6) ActorVersion() actorstypes.Version { + return actorstypes.Version6 +} + +func (s *state6) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/verifreg/v7.go b/chain/actors/builtin/verifreg/v7.go index c3b49a305..0f9a4301c 100644 --- a/chain/actors/builtin/verifreg/v7.go +++ b/chain/actors/builtin/verifreg/v7.go @@ -1,11 +1,14 @@ package verifreg import ( + "fmt" + "github.com/ipfs/go-cid" "golang.org/x/xerrors" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" verifreg9 "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" verifreg7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/verifreg" @@ -113,3 +116,20 @@ func (s *state7) GetClaims(providerIdAddr address.Address) (map[verifreg9.ClaimI return nil, xerrors.Errorf("unsupported in actors v7") } + +func (s *state7) ActorKey() string { + return actors.VerifregKey +} + +func (s *state7) ActorVersion() actorstypes.Version { + return actorstypes.Version7 +} + +func (s *state7) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/verifreg/v8.go b/chain/actors/builtin/verifreg/v8.go index 36d219fa0..8bd524635 100644 --- a/chain/actors/builtin/verifreg/v8.go +++ b/chain/actors/builtin/verifreg/v8.go @@ -1,11 +1,14 @@ package verifreg import ( + "fmt" + "github.com/ipfs/go-cid" "golang.org/x/xerrors" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" builtin8 "github.com/filecoin-project/go-state-types/builtin" adt8 "github.com/filecoin-project/go-state-types/builtin/v8/util/adt" verifreg8 "github.com/filecoin-project/go-state-types/builtin/v8/verifreg" @@ -113,3 +116,20 @@ func (s *state8) GetClaims(providerIdAddr address.Address) (map[verifreg9.ClaimI return nil, xerrors.Errorf("unsupported in actors v8") } + +func (s *state8) ActorKey() string { + return actors.VerifregKey +} + +func (s *state8) ActorVersion() actorstypes.Version { + return actorstypes.Version8 +} + +func (s *state8) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/verifreg/v9.go b/chain/actors/builtin/verifreg/v9.go index 5c84c7041..22768b22d 100644 --- a/chain/actors/builtin/verifreg/v9.go +++ b/chain/actors/builtin/verifreg/v9.go @@ -1,11 +1,14 @@ package verifreg import ( + "fmt" + "github.com/ipfs/go-cid" "golang.org/x/xerrors" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" builtin9 "github.com/filecoin-project/go-state-types/builtin" adt9 "github.com/filecoin-project/go-state-types/builtin/v9/util/adt" @@ -113,3 +116,20 @@ func (s *state9) GetClaims(providerIdAddr address.Address) (map[verifreg9.ClaimI return s.LoadClaimsToMap(s.store, providerIdAddr) } + +func (s *state9) ActorKey() string { + return actors.VerifregKey +} + +func (s *state9) ActorVersion() actorstypes.Version { + return actorstypes.Version9 +} + +func (s *state9) Code() cid.Cid { + code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey()) + if !ok { + panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion())) + } + + return code +} diff --git a/chain/actors/builtin/verifreg/verifreg.go b/chain/actors/builtin/verifreg/verifreg.go index 300307dbb..37a73842a 100644 --- a/chain/actors/builtin/verifreg/verifreg.go +++ b/chain/actors/builtin/verifreg/verifreg.go @@ -1,6 +1,7 @@ package verifreg import ( + "github.com/ipfs/go-cid" "golang.org/x/xerrors" "github.com/filecoin-project/go-address" @@ -109,6 +110,10 @@ func MakeState(store adt.Store, av actorstypes.Version, rootKeyAddress address.A type State interface { cbor.Marshaler + Code() cid.Cid + ActorKey() string + ActorVersion() actorstypes.Version + RootKey() (address.Address, error) VerifiedClientDataCap(address.Address) (bool, abi.StoragePower, error) VerifierDataCap(address.Address) (bool, abi.StoragePower, error) @@ -121,3 +126,17 @@ type State interface { GetClaims(providerIdAddr address.Address) (map[verifregtypes.ClaimId]verifregtypes.Claim, error) GetState() interface{} } + +func AllCodes() []cid.Cid { + return []cid.Cid{ + (&state0{}).Code(), + (&state2{}).Code(), + (&state3{}).Code(), + (&state4{}).Code(), + (&state5{}).Code(), + (&state6{}).Code(), + (&state7{}).Code(), + (&state8{}).Code(), + (&state9{}).Code(), + } +} diff --git a/lib/consensus/raft/config.go b/lib/consensus/raft/config.go index a3a5d35f6..983e4cc4d 100644 --- a/lib/consensus/raft/config.go +++ b/lib/consensus/raft/config.go @@ -97,8 +97,8 @@ func NewClusterRaftConfig(userRaftConfig *config.UserRaftConfig) *ClusterRaftCon } -//// Validate checks that this configuration has working values, -//// at least in appearance. +// // Validate checks that this configuration has working values, +// // at least in appearance. func ValidateConfig(cfg *ClusterRaftConfig) error { if cfg.RaftConfig == nil { return xerrors.Errorf("no hashicorp/raft.Config") From 4f513692f9b7871b6c21fb7987b97684d64c7d56 Mon Sep 17 00:00:00 2001 From: frrist Date: Wed, 16 Nov 2022 15:46:32 -0800 Subject: [PATCH 2/3] fix: update paych mock to sat interface --- chain/actors/builtin/paych/mock/mock.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/chain/actors/builtin/paych/mock/mock.go b/chain/actors/builtin/paych/mock/mock.go index 729db5924..46b4a9214 100644 --- a/chain/actors/builtin/paych/mock/mock.go +++ b/chain/actors/builtin/paych/mock/mock.go @@ -5,8 +5,11 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" + "github.com/ipfs/go-cid" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/builtin/paych" ) @@ -18,6 +21,18 @@ type mockState struct { lanes map[uint64]paych.LaneState } +func (ms *mockState) Code() cid.Cid { + panic("paych mock does not have CID") +} + +func (ms *mockState) ActorKey() string { + return actors.PaychKey +} + +func (ms *mockState) ActorVersion() actorstypes.Version { + panic("paych mock is unversioned") +} + func (ms *mockState) GetState() interface{} { panic("implement me") } From 0ae02be001502b17393423782634a066869bec34 Mon Sep 17 00:00:00 2001 From: frrist Date: Wed, 16 Nov 2022 16:24:38 -0800 Subject: [PATCH 3/3] I love code gen somuchss --- chain/actors/builtin/paych/mock/mock.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/chain/actors/builtin/paych/mock/mock.go b/chain/actors/builtin/paych/mock/mock.go index 46b4a9214..8b8624ac8 100644 --- a/chain/actors/builtin/paych/mock/mock.go +++ b/chain/actors/builtin/paych/mock/mock.go @@ -3,11 +3,12 @@ package mock import ( "io" + "github.com/ipfs/go-cid" + "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" - "github.com/ipfs/go-cid" "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/builtin/paych"