From 5086d9569f60bb28ee245feac0f2e21e993a36f3 Mon Sep 17 00:00:00 2001 From: Steph Samson Date: Mon, 27 Feb 2023 18:38:14 -0800 Subject: [PATCH] chore: add actors v13 --- chain/actors/actors.go | 4 +- chain/actors/builtin/datacap/datacap.go | 22 +- chain/actors/builtin/datacap/v12.go | 92 +++ chain/actors/builtin/datacap/v13.go | 92 +++ chain/actors/builtin/init/init.go | 22 +- chain/actors/builtin/init/v12.go | 151 +++++ chain/actors/builtin/init/v13.go | 151 +++++ chain/actors/builtin/market/market.go | 10 + chain/actors/builtin/market/v12.go | 256 +++++++ chain/actors/builtin/market/v13.go | 256 +++++++ chain/actors/builtin/miner/miner.go | 20 +- chain/actors/builtin/miner/mocks/state.go | 26 +- chain/actors/builtin/miner/v12.go | 623 ++++++++++++++++++ chain/actors/builtin/miner/v13.go | 623 ++++++++++++++++++ chain/actors/builtin/multisig/multisig.go | 26 +- chain/actors/builtin/multisig/v12.go | 130 ++++ chain/actors/builtin/multisig/v13.go | 130 ++++ chain/actors/builtin/power/power.go | 16 +- chain/actors/builtin/power/v12.go | 186 ++++++ chain/actors/builtin/power/v13.go | 186 ++++++ chain/actors/builtin/reward/reward.go | 16 +- chain/actors/builtin/reward/v12.go | 109 +++ chain/actors/builtin/reward/v13.go | 109 +++ chain/actors/builtin/verifreg/v12.go | 172 +++++ chain/actors/builtin/verifreg/v13.go | 172 +++++ chain/actors/builtin/verifreg/verifreg.go | 16 +- go.mod | 28 +- go.sum | 50 +- lens/util/store.go | 4 +- .../miner/extraction/mocks/state.go | 2 +- 30 files changed, 3622 insertions(+), 78 deletions(-) create mode 100644 chain/actors/builtin/datacap/v12.go create mode 100644 chain/actors/builtin/datacap/v13.go create mode 100644 chain/actors/builtin/init/v12.go create mode 100644 chain/actors/builtin/init/v13.go create mode 100644 chain/actors/builtin/market/v12.go create mode 100644 chain/actors/builtin/market/v13.go create mode 100644 chain/actors/builtin/miner/v12.go create mode 100644 chain/actors/builtin/miner/v13.go create mode 100644 chain/actors/builtin/multisig/v12.go create mode 100644 chain/actors/builtin/multisig/v13.go create mode 100644 chain/actors/builtin/power/v12.go create mode 100644 chain/actors/builtin/power/v13.go create mode 100644 chain/actors/builtin/reward/v12.go create mode 100644 chain/actors/builtin/reward/v13.go create mode 100644 chain/actors/builtin/verifreg/v12.go create mode 100644 chain/actors/builtin/verifreg/v13.go diff --git a/chain/actors/actors.go b/chain/actors/actors.go index 1ef261601..e9a8d69dd 100644 --- a/chain/actors/actors.go +++ b/chain/actors/actors.go @@ -10,7 +10,7 @@ import ( builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin" builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin" builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" - "github.com/ipfs/go-cid" + cid "github.com/ipfs/go-cid" ) type Version int @@ -27,6 +27,8 @@ const ( Version9 Version = 9 Version10 Version = 10 Version11 Version = 11 + Version12 Version = 12 + Version13 Version = 13 ) const ( AccountKey = "account" diff --git a/chain/actors/builtin/datacap/datacap.go b/chain/actors/builtin/datacap/datacap.go index 6ad0df6e3..5e0bd55f7 100644 --- a/chain/actors/builtin/datacap/datacap.go +++ b/chain/actors/builtin/datacap/datacap.go @@ -6,7 +6,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" actorstypes "github.com/filecoin-project/go-state-types/actors" - builtin11 "github.com/filecoin-project/go-state-types/builtin" + builtin13 "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/go-state-types/cbor" "github.com/ipfs/go-cid" @@ -17,8 +17,8 @@ import ( ) var ( - Address = builtin11.DatacapActorAddr - Methods = builtin11.MethodsDatacap + Address = builtin13.DatacapActorAddr + Methods = builtin13.MethodsDatacap ) func Load(store adt.Store, act *types.Actor) (State, error) { @@ -38,6 +38,12 @@ func Load(store adt.Store, act *types.Actor) (State, error) { case actorstypes.Version11: return load11(store, act.Head) + case actorstypes.Version12: + return load12(store, act.Head) + + case actorstypes.Version13: + return load13(store, act.Head) + } } @@ -56,6 +62,12 @@ func MakeState(store adt.Store, av actorstypes.Version, governor address.Address case actorstypes.Version11: return make11(store, governor, bitwidth) + case actorstypes.Version12: + return make12(store, governor, bitwidth) + + case actorstypes.Version13: + return make13(store, governor, bitwidth) + default: return nil, xerrors.Errorf("datacap actor only valid for actors v9 and above, got %d", av) } @@ -83,6 +95,8 @@ func AllCodes() []cid.Cid { (&state9{}).Code(), (&state10{}).Code(), (&state11{}).Code(), + (&state12{}).Code(), + (&state13{}).Code(), } } @@ -91,5 +105,7 @@ func VersionCodes() map[actors.Version]cid.Cid { actors.Version9: (&state9{}).Code(), actors.Version10: (&state10{}).Code(), actors.Version11: (&state11{}).Code(), + actors.Version12: (&state12{}).Code(), + actors.Version13: (&state13{}).Code(), } } diff --git a/chain/actors/builtin/datacap/v12.go b/chain/actors/builtin/datacap/v12.go new file mode 100644 index 000000000..f02f1bc1b --- /dev/null +++ b/chain/actors/builtin/datacap/v12.go @@ -0,0 +1,92 @@ +package datacap + +import ( + "crypto/sha256" + "fmt" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + "github.com/ipfs/go-cid" + + "github.com/filecoin-project/lily/chain/actors" + "github.com/filecoin-project/lotus/chain/actors/adt" + + datacap12 "github.com/filecoin-project/go-state-types/builtin/v12/datacap" + adt12 "github.com/filecoin-project/go-state-types/builtin/v12/util/adt" +) + +var _ State = (*state12)(nil) + +func load12(store adt.Store, root cid.Cid) (State, error) { + out := state12{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make12(store adt.Store, governor address.Address, bitwidth uint64) (State, error) { + out := state12{store: store} + s, err := datacap12.ConstructState(store, governor, bitwidth) + if err != nil { + return nil, err + } + + out.State = *s + + return &out, nil +} + +type state12 struct { + datacap12.State + store adt.Store +} + +func (s *state12) Governor() (address.Address, error) { + return s.State.Governor, nil +} + +func (s *state12) GetState() interface{} { + return &s.State +} + +func (s *state12) ForEachClient(cb func(addr address.Address, dcap abi.StoragePower) error) error { + return forEachClient(s.store, actors.Version12, s.VerifiedClients, cb) +} + +func (s *state12) VerifiedClients() (adt.Map, error) { + return adt12.AsMap(s.store, s.Token.Balances, int(s.Token.HamtBitWidth)) +} + +func (s *state12) VerifiedClientDataCap(addr address.Address) (bool, abi.StoragePower, error) { + return getDataCap(s.store, actors.Version12, s.VerifiedClients, addr) +} + +func (s *state12) VerifiedClientsMapBitWidth() int { + return int(s.Token.HamtBitWidth) +} + +func (s *state12) VerifiedClientsMapHashFunction() func(input []byte) []byte { + return func(input []byte) []byte { + res := sha256.Sum256(input) + return res[:] + } +} + +func (s *state12) ActorKey() string { + return actors.DatacapKey +} + +func (s *state12) ActorVersion() actors.Version { + return actors.Version12 +} + +func (s *state12) 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/v13.go b/chain/actors/builtin/datacap/v13.go new file mode 100644 index 000000000..d1171cb1e --- /dev/null +++ b/chain/actors/builtin/datacap/v13.go @@ -0,0 +1,92 @@ +package datacap + +import ( + "crypto/sha256" + "fmt" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + "github.com/ipfs/go-cid" + + "github.com/filecoin-project/lily/chain/actors" + "github.com/filecoin-project/lotus/chain/actors/adt" + + datacap13 "github.com/filecoin-project/go-state-types/builtin/v13/datacap" + adt13 "github.com/filecoin-project/go-state-types/builtin/v13/util/adt" +) + +var _ State = (*state13)(nil) + +func load13(store adt.Store, root cid.Cid) (State, error) { + out := state13{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make13(store adt.Store, governor address.Address, bitwidth uint64) (State, error) { + out := state13{store: store} + s, err := datacap13.ConstructState(store, governor, bitwidth) + if err != nil { + return nil, err + } + + out.State = *s + + return &out, nil +} + +type state13 struct { + datacap13.State + store adt.Store +} + +func (s *state13) Governor() (address.Address, error) { + return s.State.Governor, nil +} + +func (s *state13) GetState() interface{} { + return &s.State +} + +func (s *state13) ForEachClient(cb func(addr address.Address, dcap abi.StoragePower) error) error { + return forEachClient(s.store, actors.Version13, s.VerifiedClients, cb) +} + +func (s *state13) VerifiedClients() (adt.Map, error) { + return adt13.AsMap(s.store, s.Token.Balances, int(s.Token.HamtBitWidth)) +} + +func (s *state13) VerifiedClientDataCap(addr address.Address) (bool, abi.StoragePower, error) { + return getDataCap(s.store, actors.Version13, s.VerifiedClients, addr) +} + +func (s *state13) VerifiedClientsMapBitWidth() int { + return int(s.Token.HamtBitWidth) +} + +func (s *state13) VerifiedClientsMapHashFunction() func(input []byte) []byte { + return func(input []byte) []byte { + res := sha256.Sum256(input) + return res[:] + } +} + +func (s *state13) ActorKey() string { + return actors.DatacapKey +} + +func (s *state13) ActorVersion() actors.Version { + return actors.Version13 +} + +func (s *state13) 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/init.go b/chain/actors/builtin/init/init.go index e922a40ae..103b90971 100644 --- a/chain/actors/builtin/init/init.go +++ b/chain/actors/builtin/init/init.go @@ -28,14 +28,14 @@ import ( builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" - builtin11 "github.com/filecoin-project/go-state-types/builtin" + builtin13 "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/lily/chain/actors" ) var ( - Address = builtin11.InitActorAddr - Methods = builtin11.MethodsInit + Address = builtin13.InitActorAddr + Methods = builtin13.MethodsInit ) func Load(store adt.Store, act *types.Actor) (State, error) { @@ -58,6 +58,12 @@ func Load(store adt.Store, act *types.Actor) (State, error) { case actors.Version11: return load11(store, act.Head) + case actors.Version12: + return load12(store, act.Head) + + case actors.Version13: + return load13(store, act.Head) + } } @@ -125,6 +131,12 @@ func MakeState(store adt.Store, av actors.Version, networkName string) (State, e case actors.Version11: return make11(store, networkName) + case actors.Version12: + return make12(store, networkName) + + case actors.Version13: + return make13(store, networkName) + } return nil, fmt.Errorf("unknown actor version %d", av) } @@ -176,6 +188,8 @@ func AllCodes() []cid.Cid { (&state9{}).Code(), (&state10{}).Code(), (&state11{}).Code(), + (&state12{}).Code(), + (&state13{}).Code(), } } @@ -192,5 +206,7 @@ func VersionCodes() map[actors.Version]cid.Cid { actors.Version9: (&state9{}).Code(), actors.Version10: (&state10{}).Code(), actors.Version11: (&state11{}).Code(), + actors.Version12: (&state12{}).Code(), + actors.Version13: (&state13{}).Code(), } } diff --git a/chain/actors/builtin/init/v12.go b/chain/actors/builtin/init/v12.go new file mode 100644 index 000000000..ed787f6f6 --- /dev/null +++ b/chain/actors/builtin/init/v12.go @@ -0,0 +1,151 @@ +// Code generated by: `make actors-gen`. DO NOT EDIT. + +package init + +import ( + "fmt" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/lily/chain/actors" + "github.com/ipfs/go-cid" + cbg "github.com/whyrusleeping/cbor-gen" + + "github.com/filecoin-project/lotus/chain/actors/adt" + "github.com/filecoin-project/lotus/node/modules/dtypes" + + "crypto/sha256" + + builtin12 "github.com/filecoin-project/go-state-types/builtin" + init12 "github.com/filecoin-project/go-state-types/builtin/v12/init" + adt12 "github.com/filecoin-project/go-state-types/builtin/v12/util/adt" +) + +var _ State = (*state12)(nil) + +func load12(store adt.Store, root cid.Cid) (State, error) { + out := state12{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make12(store adt.Store, networkName string) (State, error) { + out := state12{store: store} + + s, err := init12.ConstructState(store, networkName) + if err != nil { + return nil, err + } + + out.State = *s + + return &out, nil +} + +type state12 struct { + init12.State + store adt.Store +} + +func (s *state12) ResolveAddress(address address.Address) (address.Address, bool, error) { + return s.State.ResolveAddress(s.store, address) +} + +func (s *state12) MapAddressToNewID(address address.Address) (address.Address, error) { + return s.State.MapAddressToNewID(s.store, address) +} + +func (s *state12) ForEachActor(cb func(id abi.ActorID, address address.Address) error) error { + addrs, err := adt12.AsMap(s.store, s.State.AddressMap, builtin12.DefaultHamtBitwidth) + if err != nil { + return err + } + var actorID cbg.CborInt + return addrs.ForEach(&actorID, func(key string) error { + addr, err := address.NewFromBytes([]byte(key)) + if err != nil { + return err + } + return cb(abi.ActorID(actorID), addr) + }) +} + +func (s *state12) NetworkName() (dtypes.NetworkName, error) { + return dtypes.NetworkName(s.State.NetworkName), nil +} + +func (s *state12) SetNetworkName(name string) error { + s.State.NetworkName = name + return nil +} + +func (s *state12) SetNextID(id abi.ActorID) error { + s.State.NextID = id + return nil +} + +func (s *state12) Remove(addrs ...address.Address) (err error) { + m, err := adt12.AsMap(s.store, s.State.AddressMap, builtin12.DefaultHamtBitwidth) + if err != nil { + return err + } + for _, addr := range addrs { + if err = m.Delete(abi.AddrKey(addr)); err != nil { + return fmt.Errorf("failed to delete entry for address: %s; err: %w", addr, err) + } + } + amr, err := m.Root() + if err != nil { + return fmt.Errorf("failed to get address map root: %w", err) + } + s.State.AddressMap = amr + return nil +} + +func (s *state12) SetAddressMap(mcid cid.Cid) error { + s.State.AddressMap = mcid + return nil +} + +func (s *state12) AddressMap() (adt.Map, error) { + return adt12.AsMap(s.store, s.State.AddressMap, builtin12.DefaultHamtBitwidth) +} + +func (s *state12) AddressMapBitWidth() int { + + return builtin12.DefaultHamtBitwidth + +} + +func (s *state12) AddressMapHashFunction() func(input []byte) []byte { + + return func(input []byte) []byte { + res := sha256.Sum256(input) + return res[:] + } + +} + +func (s *state12) GetState() interface{} { + return &s.State +} + +func (s *state12) ActorKey() string { + return actors.InitKey +} + +func (s *state12) ActorVersion() actors.Version { + return actors.Version12 +} + +func (s *state12) 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/v13.go b/chain/actors/builtin/init/v13.go new file mode 100644 index 000000000..69a7c8ebd --- /dev/null +++ b/chain/actors/builtin/init/v13.go @@ -0,0 +1,151 @@ +// Code generated by: `make actors-gen`. DO NOT EDIT. + +package init + +import ( + "fmt" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/lily/chain/actors" + "github.com/ipfs/go-cid" + cbg "github.com/whyrusleeping/cbor-gen" + + "github.com/filecoin-project/lotus/chain/actors/adt" + "github.com/filecoin-project/lotus/node/modules/dtypes" + + "crypto/sha256" + + builtin13 "github.com/filecoin-project/go-state-types/builtin" + init13 "github.com/filecoin-project/go-state-types/builtin/v13/init" + adt13 "github.com/filecoin-project/go-state-types/builtin/v13/util/adt" +) + +var _ State = (*state13)(nil) + +func load13(store adt.Store, root cid.Cid) (State, error) { + out := state13{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make13(store adt.Store, networkName string) (State, error) { + out := state13{store: store} + + s, err := init13.ConstructState(store, networkName) + if err != nil { + return nil, err + } + + out.State = *s + + return &out, nil +} + +type state13 struct { + init13.State + store adt.Store +} + +func (s *state13) ResolveAddress(address address.Address) (address.Address, bool, error) { + return s.State.ResolveAddress(s.store, address) +} + +func (s *state13) MapAddressToNewID(address address.Address) (address.Address, error) { + return s.State.MapAddressToNewID(s.store, address) +} + +func (s *state13) ForEachActor(cb func(id abi.ActorID, address address.Address) error) error { + addrs, err := adt13.AsMap(s.store, s.State.AddressMap, builtin13.DefaultHamtBitwidth) + if err != nil { + return err + } + var actorID cbg.CborInt + return addrs.ForEach(&actorID, func(key string) error { + addr, err := address.NewFromBytes([]byte(key)) + if err != nil { + return err + } + return cb(abi.ActorID(actorID), addr) + }) +} + +func (s *state13) NetworkName() (dtypes.NetworkName, error) { + return dtypes.NetworkName(s.State.NetworkName), nil +} + +func (s *state13) SetNetworkName(name string) error { + s.State.NetworkName = name + return nil +} + +func (s *state13) SetNextID(id abi.ActorID) error { + s.State.NextID = id + return nil +} + +func (s *state13) Remove(addrs ...address.Address) (err error) { + m, err := adt13.AsMap(s.store, s.State.AddressMap, builtin13.DefaultHamtBitwidth) + if err != nil { + return err + } + for _, addr := range addrs { + if err = m.Delete(abi.AddrKey(addr)); err != nil { + return fmt.Errorf("failed to delete entry for address: %s; err: %w", addr, err) + } + } + amr, err := m.Root() + if err != nil { + return fmt.Errorf("failed to get address map root: %w", err) + } + s.State.AddressMap = amr + return nil +} + +func (s *state13) SetAddressMap(mcid cid.Cid) error { + s.State.AddressMap = mcid + return nil +} + +func (s *state13) AddressMap() (adt.Map, error) { + return adt13.AsMap(s.store, s.State.AddressMap, builtin13.DefaultHamtBitwidth) +} + +func (s *state13) AddressMapBitWidth() int { + + return builtin13.DefaultHamtBitwidth + +} + +func (s *state13) AddressMapHashFunction() func(input []byte) []byte { + + return func(input []byte) []byte { + res := sha256.Sum256(input) + return res[:] + } + +} + +func (s *state13) GetState() interface{} { + return &s.State +} + +func (s *state13) ActorKey() string { + return actors.InitKey +} + +func (s *state13) ActorVersion() actors.Version { + return actors.Version13 +} + +func (s *state13) 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/market.go b/chain/actors/builtin/market/market.go index 9123ec11b..1658a20cf 100644 --- a/chain/actors/builtin/market/market.go +++ b/chain/actors/builtin/market/market.go @@ -60,6 +60,12 @@ func Load(store adt.Store, act *types.Actor) (State, error) { case actors.Version11: return load11(store, act.Head) + case actors.Version12: + return load12(store, act.Head) + + case actors.Version13: + return load13(store, act.Head) + } } @@ -177,6 +183,8 @@ func AllCodes() []cid.Cid { (&state9{}).Code(), (&state10{}).Code(), (&state11{}).Code(), + (&state12{}).Code(), + (&state13{}).Code(), } } @@ -193,5 +201,7 @@ func VersionCodes() map[actors.Version]cid.Cid { actors.Version9: (&state9{}).Code(), actors.Version10: (&state10{}).Code(), actors.Version11: (&state11{}).Code(), + actors.Version12: (&state12{}).Code(), + actors.Version13: (&state13{}).Code(), } } diff --git a/chain/actors/builtin/market/v12.go b/chain/actors/builtin/market/v12.go new file mode 100644 index 000000000..ffdbb88ee --- /dev/null +++ b/chain/actors/builtin/market/v12.go @@ -0,0 +1,256 @@ +// Code generated by: `make actors-gen`. DO NOT EDIT. + +package market + +import ( + "bytes" + "fmt" + + "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/lily/chain/actors" + "github.com/ipfs/go-cid" + cbg "github.com/whyrusleeping/cbor-gen" + "golang.org/x/xerrors" + + "github.com/filecoin-project/lotus/chain/actors/adt" + + verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" + + market12 "github.com/filecoin-project/go-state-types/builtin/v12/market" + adt12 "github.com/filecoin-project/go-state-types/builtin/v12/util/adt" + markettypes "github.com/filecoin-project/go-state-types/builtin/v9/market" +) + +var _ State = (*state12)(nil) + +func load12(store adt.Store, root cid.Cid) (State, error) { + out := state12{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make12(store adt.Store) (State, error) { + out := state12{store: store} + + s, err := market12.ConstructState(store) + if err != nil { + return nil, err + } + + out.State = *s + + return &out, nil +} + +type state12 struct { + market12.State + store adt.Store +} + +func (s *state12) StatesChanged(otherState State) (bool, error) { + otherState12, ok := otherState.(*state12) + if !ok { + // there's no way to compare different versions of the state, so let's + // just say that means the state of balances has changed + return true, nil + } + return !s.State.States.Equals(otherState12.State.States), nil +} + +func (s *state12) States() (DealStates, error) { + stateArray, err := adt12.AsArray(s.store, s.State.States, market12.StatesAmtBitwidth) + if err != nil { + return nil, err + } + return &dealStates12{stateArray}, nil +} + +func (s *state12) ProposalsChanged(otherState State) (bool, error) { + otherState12, ok := otherState.(*state12) + if !ok { + // there's no way to compare different versions of the state, so let's + // just say that means the state of balances has changed + return true, nil + } + return !s.State.Proposals.Equals(otherState12.State.Proposals), nil +} + +func (s *state12) Proposals() (DealProposals, error) { + proposalArray, err := adt12.AsArray(s.store, s.State.Proposals, market12.ProposalsAmtBitwidth) + if err != nil { + return nil, err + } + return &dealProposals12{proposalArray}, nil +} + +type dealStates12 struct { + adt.Array +} + +func (s *dealStates12) Get(dealID abi.DealID) (*DealState, bool, error) { + var deal12 market12.DealState + found, err := s.Array.Get(uint64(dealID), &deal12) + if err != nil { + return nil, false, err + } + if !found { + return nil, false, nil + } + deal := fromV12DealState(deal12) + return &deal, true, nil +} + +func (s *dealStates12) ForEach(cb func(dealID abi.DealID, ds DealState) error) error { + var ds12 market12.DealState + return s.Array.ForEach(&ds12, func(idx int64) error { + return cb(abi.DealID(idx), fromV12DealState(ds12)) + }) +} + +func (s *dealStates12) decode(val *cbg.Deferred) (*DealState, error) { + var ds12 market12.DealState + if err := ds12.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { + return nil, err + } + ds := fromV12DealState(ds12) + return &ds, nil +} + +func (s *dealStates12) array() adt.Array { + return s.Array +} + +func fromV12DealState(v12 market12.DealState) DealState { + ret := DealState{ + SectorStartEpoch: v12.SectorStartEpoch, + LastUpdatedEpoch: v12.LastUpdatedEpoch, + SlashEpoch: v12.SlashEpoch, + VerifiedClaim: 0, + } + + ret.VerifiedClaim = verifregtypes.AllocationId(v12.VerifiedClaim) + + return ret +} + +type dealProposals12 struct { + adt.Array +} + +func (s *dealProposals12) Get(dealID abi.DealID) (*DealProposal, bool, error) { + var proposal12 market12.DealProposal + found, err := s.Array.Get(uint64(dealID), &proposal12) + if err != nil { + return nil, false, err + } + if !found { + return nil, false, nil + } + + proposal, err := fromV12DealProposal(proposal12) + if err != nil { + return nil, true, xerrors.Errorf("decoding proposal: %w", err) + } + + return &proposal, true, nil +} + +func (s *dealProposals12) ForEach(cb func(dealID abi.DealID, dp DealProposal) error) error { + var dp12 market12.DealProposal + return s.Array.ForEach(&dp12, func(idx int64) error { + dp, err := fromV12DealProposal(dp12) + if err != nil { + return xerrors.Errorf("decoding proposal: %w", err) + } + + return cb(abi.DealID(idx), dp) + }) +} + +func (s *dealProposals12) decode(val *cbg.Deferred) (*DealProposal, error) { + var dp12 market12.DealProposal + if err := dp12.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { + return nil, err + } + + dp, err := fromV12DealProposal(dp12) + if err != nil { + return nil, err + } + + return &dp, nil +} + +func (s *dealProposals12) array() adt.Array { + return s.Array +} + +func fromV12DealProposal(v12 market12.DealProposal) (DealProposal, error) { + + label, err := fromV12Label(v12.Label) + + if err != nil { + return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err) + } + + return DealProposal{ + PieceCID: v12.PieceCID, + PieceSize: v12.PieceSize, + VerifiedDeal: v12.VerifiedDeal, + Client: v12.Client, + Provider: v12.Provider, + + Label: label, + + StartEpoch: v12.StartEpoch, + EndEpoch: v12.EndEpoch, + StoragePricePerEpoch: v12.StoragePricePerEpoch, + + ProviderCollateral: v12.ProviderCollateral, + ClientCollateral: v12.ClientCollateral, + }, nil +} + +func (s *state12) DealProposalsAmtBitwidth() int { + return market12.ProposalsAmtBitwidth +} + +func (s *state12) DealStatesAmtBitwidth() int { + return market12.StatesAmtBitwidth +} + +func (s *state12) ActorKey() string { + return actors.MarketKey +} + +func (s *state12) ActorVersion() actors.Version { + return actors.Version12 +} + +func (s *state12) 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 +} + +func fromV12Label(v12 market12.DealLabel) (DealLabel, error) { + if v12.IsString() { + str, err := v12.ToString() + if err != nil { + return markettypes.EmptyDealLabel, xerrors.Errorf("failed to convert string label to string: %w", err) + } + return markettypes.NewLabelFromString(str) + } + + bs, err := v12.ToBytes() + if err != nil { + return markettypes.EmptyDealLabel, xerrors.Errorf("failed to convert bytes label to bytes: %w", err) + } + return markettypes.NewLabelFromBytes(bs) +} diff --git a/chain/actors/builtin/market/v13.go b/chain/actors/builtin/market/v13.go new file mode 100644 index 000000000..5924e1746 --- /dev/null +++ b/chain/actors/builtin/market/v13.go @@ -0,0 +1,256 @@ +// Code generated by: `make actors-gen`. DO NOT EDIT. + +package market + +import ( + "bytes" + "fmt" + + "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/lily/chain/actors" + "github.com/ipfs/go-cid" + cbg "github.com/whyrusleeping/cbor-gen" + "golang.org/x/xerrors" + + "github.com/filecoin-project/lotus/chain/actors/adt" + + verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" + + market13 "github.com/filecoin-project/go-state-types/builtin/v13/market" + adt13 "github.com/filecoin-project/go-state-types/builtin/v13/util/adt" + markettypes "github.com/filecoin-project/go-state-types/builtin/v9/market" +) + +var _ State = (*state13)(nil) + +func load13(store adt.Store, root cid.Cid) (State, error) { + out := state13{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make13(store adt.Store) (State, error) { + out := state13{store: store} + + s, err := market13.ConstructState(store) + if err != nil { + return nil, err + } + + out.State = *s + + return &out, nil +} + +type state13 struct { + market13.State + store adt.Store +} + +func (s *state13) StatesChanged(otherState State) (bool, error) { + otherState13, ok := otherState.(*state13) + if !ok { + // there's no way to compare different versions of the state, so let's + // just say that means the state of balances has changed + return true, nil + } + return !s.State.States.Equals(otherState13.State.States), nil +} + +func (s *state13) States() (DealStates, error) { + stateArray, err := adt13.AsArray(s.store, s.State.States, market13.StatesAmtBitwidth) + if err != nil { + return nil, err + } + return &dealStates13{stateArray}, nil +} + +func (s *state13) ProposalsChanged(otherState State) (bool, error) { + otherState13, ok := otherState.(*state13) + if !ok { + // there's no way to compare different versions of the state, so let's + // just say that means the state of balances has changed + return true, nil + } + return !s.State.Proposals.Equals(otherState13.State.Proposals), nil +} + +func (s *state13) Proposals() (DealProposals, error) { + proposalArray, err := adt13.AsArray(s.store, s.State.Proposals, market13.ProposalsAmtBitwidth) + if err != nil { + return nil, err + } + return &dealProposals13{proposalArray}, nil +} + +type dealStates13 struct { + adt.Array +} + +func (s *dealStates13) Get(dealID abi.DealID) (*DealState, bool, error) { + var deal13 market13.DealState + found, err := s.Array.Get(uint64(dealID), &deal13) + if err != nil { + return nil, false, err + } + if !found { + return nil, false, nil + } + deal := fromV13DealState(deal13) + return &deal, true, nil +} + +func (s *dealStates13) ForEach(cb func(dealID abi.DealID, ds DealState) error) error { + var ds13 market13.DealState + return s.Array.ForEach(&ds13, func(idx int64) error { + return cb(abi.DealID(idx), fromV13DealState(ds13)) + }) +} + +func (s *dealStates13) decode(val *cbg.Deferred) (*DealState, error) { + var ds13 market13.DealState + if err := ds13.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { + return nil, err + } + ds := fromV13DealState(ds13) + return &ds, nil +} + +func (s *dealStates13) array() adt.Array { + return s.Array +} + +func fromV13DealState(v13 market13.DealState) DealState { + ret := DealState{ + SectorStartEpoch: v13.SectorStartEpoch, + LastUpdatedEpoch: v13.LastUpdatedEpoch, + SlashEpoch: v13.SlashEpoch, + VerifiedClaim: 0, + } + + ret.VerifiedClaim = verifregtypes.AllocationId(v13.VerifiedClaim) + + return ret +} + +type dealProposals13 struct { + adt.Array +} + +func (s *dealProposals13) Get(dealID abi.DealID) (*DealProposal, bool, error) { + var proposal13 market13.DealProposal + found, err := s.Array.Get(uint64(dealID), &proposal13) + if err != nil { + return nil, false, err + } + if !found { + return nil, false, nil + } + + proposal, err := fromV13DealProposal(proposal13) + if err != nil { + return nil, true, xerrors.Errorf("decoding proposal: %w", err) + } + + return &proposal, true, nil +} + +func (s *dealProposals13) ForEach(cb func(dealID abi.DealID, dp DealProposal) error) error { + var dp13 market13.DealProposal + return s.Array.ForEach(&dp13, func(idx int64) error { + dp, err := fromV13DealProposal(dp13) + if err != nil { + return xerrors.Errorf("decoding proposal: %w", err) + } + + return cb(abi.DealID(idx), dp) + }) +} + +func (s *dealProposals13) decode(val *cbg.Deferred) (*DealProposal, error) { + var dp13 market13.DealProposal + if err := dp13.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { + return nil, err + } + + dp, err := fromV13DealProposal(dp13) + if err != nil { + return nil, err + } + + return &dp, nil +} + +func (s *dealProposals13) array() adt.Array { + return s.Array +} + +func fromV13DealProposal(v13 market13.DealProposal) (DealProposal, error) { + + label, err := fromV13Label(v13.Label) + + if err != nil { + return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err) + } + + return DealProposal{ + PieceCID: v13.PieceCID, + PieceSize: v13.PieceSize, + VerifiedDeal: v13.VerifiedDeal, + Client: v13.Client, + Provider: v13.Provider, + + Label: label, + + StartEpoch: v13.StartEpoch, + EndEpoch: v13.EndEpoch, + StoragePricePerEpoch: v13.StoragePricePerEpoch, + + ProviderCollateral: v13.ProviderCollateral, + ClientCollateral: v13.ClientCollateral, + }, nil +} + +func (s *state13) DealProposalsAmtBitwidth() int { + return market13.ProposalsAmtBitwidth +} + +func (s *state13) DealStatesAmtBitwidth() int { + return market13.StatesAmtBitwidth +} + +func (s *state13) ActorKey() string { + return actors.MarketKey +} + +func (s *state13) ActorVersion() actors.Version { + return actors.Version13 +} + +func (s *state13) 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 +} + +func fromV13Label(v13 market13.DealLabel) (DealLabel, error) { + if v13.IsString() { + str, err := v13.ToString() + if err != nil { + return markettypes.EmptyDealLabel, xerrors.Errorf("failed to convert string label to string: %w", err) + } + return markettypes.NewLabelFromString(str) + } + + bs, err := v13.ToBytes() + if err != nil { + return markettypes.EmptyDealLabel, xerrors.Errorf("failed to convert bytes label to bytes: %w", err) + } + return markettypes.NewLabelFromBytes(bs) +} diff --git a/chain/actors/builtin/miner/miner.go b/chain/actors/builtin/miner/miner.go index 6f5b388ec..4e77ce183 100644 --- a/chain/actors/builtin/miner/miner.go +++ b/chain/actors/builtin/miner/miner.go @@ -16,7 +16,7 @@ import ( "github.com/filecoin-project/go-state-types/dline" "github.com/filecoin-project/go-state-types/proof" - miner11 "github.com/filecoin-project/go-state-types/builtin/v11/miner" + miner13 "github.com/filecoin-project/go-state-types/builtin/v13/miner" miner8 "github.com/filecoin-project/go-state-types/builtin/v8/miner" minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/lotus/chain/actors/adt" @@ -57,6 +57,12 @@ func Load(store adt.Store, act *types.Actor) (State, error) { case actors.Version11: return load11(store, act.Head) + case actors.Version12: + return load12(store, act.Head) + + case actors.Version13: + return load13(store, act.Head) + } } @@ -124,6 +130,12 @@ func MakeState(store adt.Store, av actors.Version) (State, error) { case actors.Version11: return make11(store) + case actors.Version12: + return make12(store) + + case actors.Version13: + return make13(store) + } return nil, xerrors.Errorf("unknown actor version %d", av) } @@ -221,7 +233,7 @@ type Partition interface { UnprovenSectors() (bitfield.BitField, error) } -type SectorOnChainInfo = miner11.SectorOnChainInfo +type SectorOnChainInfo = miner13.SectorOnChainInfo func PreferredSealProofTypeFromWindowPoStType(nver network.Version, proof abi.RegisteredPoStProof) (abi.RegisteredSealProof, error) { // We added support for the new proofs in network version 7, and removed support for the old @@ -342,6 +354,8 @@ func AllCodes() []cid.Cid { (&state9{}).Code(), (&state10{}).Code(), (&state11{}).Code(), + (&state12{}).Code(), + (&state13{}).Code(), } } @@ -358,5 +372,7 @@ func VersionCodes() map[actors.Version]cid.Cid { actors.Version9: (&state9{}).Code(), actors.Version10: (&state10{}).Code(), actors.Version11: (&state11{}).Code(), + actors.Version12: (&state12{}).Code(), + actors.Version13: (&state13{}).Code(), } } diff --git a/chain/actors/builtin/miner/mocks/state.go b/chain/actors/builtin/miner/mocks/state.go index 66370e042..ce352f7d1 100644 --- a/chain/actors/builtin/miner/mocks/state.go +++ b/chain/actors/builtin/miner/mocks/state.go @@ -24,7 +24,7 @@ import ( typegen "github.com/whyrusleeping/cbor-gen" - v11miner "github.com/filecoin-project/go-state-types/builtin/v11/miner" + v13miner "github.com/filecoin-project/go-state-types/builtin/v13/miner" v8miner "github.com/filecoin-project/go-state-types/builtin/v8/miner" @@ -165,14 +165,14 @@ func (_m *State) DeadlinesChanged(_a0 miner.State) (bool, error) { } // DecodeSectorOnChainInfo provides a mock function with given fields: _a0 -func (_m *State) DecodeSectorOnChainInfo(_a0 *typegen.Deferred) (v11miner.SectorOnChainInfo, error) { +func (_m *State) DecodeSectorOnChainInfo(_a0 *typegen.Deferred) (v13miner.SectorOnChainInfo, error) { ret := _m.Called(_a0) - var r0 v11miner.SectorOnChainInfo - if rf, ok := ret.Get(0).(func(*typegen.Deferred) v11miner.SectorOnChainInfo); ok { + var r0 v13miner.SectorOnChainInfo + if rf, ok := ret.Get(0).(func(*typegen.Deferred) v13miner.SectorOnChainInfo); ok { r0 = rf(_a0) } else { - r0 = ret.Get(0).(v11miner.SectorOnChainInfo) + r0 = ret.Get(0).(v13miner.SectorOnChainInfo) } var r1 error @@ -395,15 +395,15 @@ func (_m *State) GetProvingPeriodStart() (abi.ChainEpoch, error) { } // GetSector provides a mock function with given fields: _a0 -func (_m *State) GetSector(_a0 abi.SectorNumber) (*v11miner.SectorOnChainInfo, error) { +func (_m *State) GetSector(_a0 abi.SectorNumber) (*v13miner.SectorOnChainInfo, error) { ret := _m.Called(_a0) - var r0 *v11miner.SectorOnChainInfo - if rf, ok := ret.Get(0).(func(abi.SectorNumber) *v11miner.SectorOnChainInfo); ok { + var r0 *v13miner.SectorOnChainInfo + if rf, ok := ret.Get(0).(func(abi.SectorNumber) *v13miner.SectorOnChainInfo); ok { r0 = rf(_a0) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*v11miner.SectorOnChainInfo) + r0 = ret.Get(0).(*v13miner.SectorOnChainInfo) } } @@ -522,15 +522,15 @@ func (_m *State) LoadDeadline(idx uint64) (miner.Deadline, error) { } // LoadSectors provides a mock function with given fields: sectorNos -func (_m *State) LoadSectors(sectorNos *bitfield.BitField) ([]*v11miner.SectorOnChainInfo, error) { +func (_m *State) LoadSectors(sectorNos *bitfield.BitField) ([]*v13miner.SectorOnChainInfo, error) { ret := _m.Called(sectorNos) - var r0 []*v11miner.SectorOnChainInfo - if rf, ok := ret.Get(0).(func(*bitfield.BitField) []*v11miner.SectorOnChainInfo); ok { + var r0 []*v13miner.SectorOnChainInfo + if rf, ok := ret.Get(0).(func(*bitfield.BitField) []*v13miner.SectorOnChainInfo); ok { r0 = rf(sectorNos) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]*v11miner.SectorOnChainInfo) + r0 = ret.Get(0).([]*v13miner.SectorOnChainInfo) } } diff --git a/chain/actors/builtin/miner/v12.go b/chain/actors/builtin/miner/v12.go new file mode 100644 index 000000000..9c09a422b --- /dev/null +++ b/chain/actors/builtin/miner/v12.go @@ -0,0 +1,623 @@ +// Code generated by: `make actors-gen`. DO NOT EDIT. +package miner + +import ( + "bytes" + "errors" + "fmt" + + "github.com/filecoin-project/go-bitfield" + rle "github.com/filecoin-project/go-bitfield/rle" + "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/go-state-types/dline" + "github.com/filecoin-project/lily/chain/actors" + "github.com/ipfs/go-cid" + cbg "github.com/whyrusleeping/cbor-gen" + "golang.org/x/xerrors" + + minertypesv8 "github.com/filecoin-project/go-state-types/builtin/v8/miner" + "github.com/filecoin-project/lotus/chain/actors/adt" + + "crypto/sha256" + + builtin12 "github.com/filecoin-project/go-state-types/builtin" + miner12 "github.com/filecoin-project/go-state-types/builtin/v12/miner" + adt12 "github.com/filecoin-project/go-state-types/builtin/v12/util/adt" +) + +var _ State = (*state12)(nil) + +func load12(store adt.Store, root cid.Cid) (State, error) { + out := state12{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make12(store adt.Store) (State, error) { + out := state12{store: store} + out.State = miner12.State{} + return &out, nil +} + +type state12 struct { + miner12.State + store adt.Store +} + +type deadline12 struct { + miner12.Deadline + store adt.Store +} + +type partition12 struct { + miner12.Partition + store adt.Store +} + +func (s *state12) AvailableBalance(bal abi.TokenAmount) (available abi.TokenAmount, err error) { + defer func() { + if r := recover(); r != nil { + err = xerrors.Errorf("failed to get available balance: %w", r) + available = abi.NewTokenAmount(0) + } + }() + // this panics if the miner doesnt have enough funds to cover their locked pledge + available, err = s.GetAvailableBalance(bal) + return available, err +} + +func (s *state12) VestedFunds(epoch abi.ChainEpoch) (abi.TokenAmount, error) { + return s.CheckVestedFunds(s.store, epoch) +} + +func (s *state12) LockedFunds() (LockedFunds, error) { + return LockedFunds{ + VestingFunds: s.State.LockedFunds, + InitialPledgeRequirement: s.State.InitialPledge, + PreCommitDeposits: s.State.PreCommitDeposits, + }, nil +} + +func (s *state12) FeeDebt() (abi.TokenAmount, error) { + return s.State.FeeDebt, nil +} + +func (s *state12) InitialPledge() (abi.TokenAmount, error) { + return s.State.InitialPledge, nil +} + +func (s *state12) PreCommitDeposits() (abi.TokenAmount, error) { + return s.State.PreCommitDeposits, nil +} + +func (s *state12) GetSector(num abi.SectorNumber) (*SectorOnChainInfo, error) { + info, ok, err := s.State.GetSector(s.store, num) + if !ok || err != nil { + return nil, err + } + + ret := fromV12SectorOnChainInfo(*info) + return &ret, nil +} + +func (s *state12) FindSector(num abi.SectorNumber) (*SectorLocation, error) { + dlIdx, partIdx, err := s.State.FindSector(s.store, num) + if err != nil { + return nil, err + } + return &SectorLocation{ + Deadline: dlIdx, + Partition: partIdx, + }, nil +} + +func (s *state12) NumLiveSectors() (uint64, error) { + dls, err := s.State.LoadDeadlines(s.store) + if err != nil { + return 0, err + } + var total uint64 + if err := dls.ForEach(s.store, func(dlIdx uint64, dl *miner12.Deadline) error { + total += dl.LiveSectors + return nil + }); err != nil { + return 0, err + } + return total, nil +} + +// GetSectorExpiration returns the effective expiration of the given sector. +// +// If the sector does not expire early, the Early expiration field is 0. +func (s *state12) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, error) { + dls, err := s.State.LoadDeadlines(s.store) + if err != nil { + return nil, err + } + // NOTE: this can be optimized significantly. + // 1. If the sector is non-faulty, it will expire on-time (can be + // learned from the sector info). + // 2. If it's faulty, it will expire early within the first 42 entries + // of the expiration queue. + + stopErr := errors.New("stop") + out := SectorExpiration{} + err = dls.ForEach(s.store, func(dlIdx uint64, dl *miner12.Deadline) error { + partitions, err := dl.PartitionsArray(s.store) + if err != nil { + return err + } + quant := s.State.QuantSpecForDeadline(dlIdx) + var part miner12.Partition + return partitions.ForEach(&part, func(partIdx int64) error { + if found, err := part.Sectors.IsSet(uint64(num)); err != nil { + return err + } else if !found { + return nil + } + if found, err := part.Terminated.IsSet(uint64(num)); err != nil { + return err + } else if found { + // already terminated + return stopErr + } + + q, err := miner12.LoadExpirationQueue(s.store, part.ExpirationsEpochs, quant, miner12.PartitionExpirationAmtBitwidth) + if err != nil { + return err + } + var exp miner12.ExpirationSet + return q.ForEach(&exp, func(epoch int64) error { + if early, err := exp.EarlySectors.IsSet(uint64(num)); err != nil { + return err + } else if early { + out.Early = abi.ChainEpoch(epoch) + return nil + } + if onTime, err := exp.OnTimeSectors.IsSet(uint64(num)); err != nil { + return err + } else if onTime { + out.OnTime = abi.ChainEpoch(epoch) + return stopErr + } + return nil + }) + }) + }) + if err == stopErr { + err = nil + } + if err != nil { + return nil, err + } + if out.Early == 0 && out.OnTime == 0 { + return nil, xerrors.Errorf("failed to find sector %d", num) + } + return &out, nil +} + +func (s *state12) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOnChainInfo, error) { + info, ok, err := s.State.GetPrecommittedSector(s.store, num) + if !ok || err != nil { + return nil, err + } + + ret := fromV12SectorPreCommitOnChainInfo(*info) + + return &ret, nil +} + +func (s *state12) ForEachPrecommittedSector(cb func(SectorPreCommitOnChainInfo) error) error { + precommitted, err := adt12.AsMap(s.store, s.State.PreCommittedSectors, builtin12.DefaultHamtBitwidth) + if err != nil { + return err + } + + var info miner12.SectorPreCommitOnChainInfo + if err := precommitted.ForEach(&info, func(_ string) error { + return cb(fromV12SectorPreCommitOnChainInfo(info)) + }); err != nil { + return err + } + + return nil +} + +func (s *state12) LoadSectors(snos *bitfield.BitField) ([]*SectorOnChainInfo, error) { + sectors, err := miner12.LoadSectors(s.store, s.State.Sectors) + if err != nil { + return nil, err + } + + // If no sector numbers are specified, load all. + if snos == nil { + infos := make([]*SectorOnChainInfo, 0, sectors.Length()) + var info12 miner12.SectorOnChainInfo + if err := sectors.ForEach(&info12, func(_ int64) error { + info := fromV12SectorOnChainInfo(info12) + infos = append(infos, &info) + return nil + }); err != nil { + return nil, err + } + return infos, nil + } + + // Otherwise, load selected. + infos12, err := sectors.Load(*snos) + if err != nil { + return nil, err + } + infos := make([]*SectorOnChainInfo, len(infos12)) + for i, info12 := range infos12 { + info := fromV12SectorOnChainInfo(*info12) + infos[i] = &info + } + return infos, nil +} + +func (s *state12) loadAllocatedSectorNumbers() (bitfield.BitField, error) { + var allocatedSectors bitfield.BitField + err := s.store.Get(s.store.Context(), s.State.AllocatedSectors, &allocatedSectors) + return allocatedSectors, err +} + +func (s *state12) IsAllocated(num abi.SectorNumber) (bool, error) { + allocatedSectors, err := s.loadAllocatedSectorNumbers() + if err != nil { + return false, err + } + + return allocatedSectors.IsSet(uint64(num)) +} + +func (s *state12) GetProvingPeriodStart() (abi.ChainEpoch, error) { + return s.State.ProvingPeriodStart, nil +} + +func (s *state12) UnallocatedSectorNumbers(count int) ([]abi.SectorNumber, error) { + allocatedSectors, err := s.loadAllocatedSectorNumbers() + if err != nil { + return nil, err + } + + allocatedRuns, err := allocatedSectors.RunIterator() + if err != nil { + return nil, err + } + + unallocatedRuns, err := rle.Subtract( + &rle.RunSliceIterator{Runs: []rle.Run{{Val: true, Len: abi.MaxSectorNumber}}}, + allocatedRuns, + ) + if err != nil { + return nil, err + } + + iter, err := rle.BitsFromRuns(unallocatedRuns) + if err != nil { + return nil, err + } + + sectors := make([]abi.SectorNumber, 0, count) + for iter.HasNext() && len(sectors) < count { + nextNo, err := iter.Next() + if err != nil { + return nil, err + } + sectors = append(sectors, abi.SectorNumber(nextNo)) + } + + return sectors, nil +} + +func (s *state12) GetAllocatedSectors() (*bitfield.BitField, error) { + var allocatedSectors bitfield.BitField + if err := s.store.Get(s.store.Context(), s.State.AllocatedSectors, &allocatedSectors); err != nil { + return nil, err + } + + return &allocatedSectors, nil +} + +func (s *state12) LoadDeadline(idx uint64) (Deadline, error) { + dls, err := s.State.LoadDeadlines(s.store) + if err != nil { + return nil, err + } + dl, err := dls.LoadDeadline(s.store, idx) + if err != nil { + return nil, err + } + return &deadline12{*dl, s.store}, nil +} + +func (s *state12) ForEachDeadline(cb func(uint64, Deadline) error) error { + dls, err := s.State.LoadDeadlines(s.store) + if err != nil { + return err + } + return dls.ForEach(s.store, func(i uint64, dl *miner12.Deadline) error { + return cb(i, &deadline12{*dl, s.store}) + }) +} + +func (s *state12) NumDeadlines() (uint64, error) { + return miner12.WPoStPeriodDeadlines, nil +} + +func (s *state12) DeadlinesChanged(other State) (bool, error) { + other12, ok := other.(*state12) + if !ok { + // treat an upgrade as a change, always + return true, nil + } + + return !s.State.Deadlines.Equals(other12.Deadlines), nil +} + +func (s *state12) MinerInfoChanged(other State) (bool, error) { + other0, ok := other.(*state12) + if !ok { + // treat an upgrade as a change, always + return true, nil + } + return !s.State.Info.Equals(other0.State.Info), nil +} + +func (s *state12) Info() (MinerInfo, error) { + info, err := s.State.GetInfo(s.store) + if err != nil { + return MinerInfo{}, err + } + + mi := MinerInfo{ + Owner: info.Owner, + Worker: info.Worker, + ControlAddresses: info.ControlAddresses, + + PendingWorkerKey: (*WorkerKeyChange)(info.PendingWorkerKey), + + PeerId: info.PeerId, + Multiaddrs: info.Multiaddrs, + WindowPoStProofType: info.WindowPoStProofType, + SectorSize: info.SectorSize, + WindowPoStPartitionSectors: info.WindowPoStPartitionSectors, + ConsensusFaultElapsed: info.ConsensusFaultElapsed, + + Beneficiary: info.Beneficiary, + BeneficiaryTerm: BeneficiaryTerm(info.BeneficiaryTerm), + PendingBeneficiaryTerm: (*PendingBeneficiaryChange)(info.PendingBeneficiaryTerm), + } + + return mi, nil +} + +func (s *state12) DeadlineInfo(epoch abi.ChainEpoch) (*dline.Info, error) { + return s.State.RecordedDeadlineInfo(epoch), nil +} + +func (s *state12) DeadlineCronActive() (bool, error) { + return s.State.DeadlineCronActive, nil +} + +func (s *state12) SectorsArray() (adt.Array, error) { + return adt12.AsArray(s.store, s.Sectors, miner12.SectorsAmtBitwidth) +} + +func (s *state12) DecodeSectorOnChainInfo(val *cbg.Deferred) (SectorOnChainInfo, error) { + var si miner12.SectorOnChainInfo + err := si.UnmarshalCBOR(bytes.NewReader(val.Raw)) + if err != nil { + return SectorOnChainInfo{}, err + } + + return fromV12SectorOnChainInfo(si), nil +} + +func (s *state12) PrecommitsMap() (adt.Map, error) { + return adt12.AsMap(s.store, s.PreCommittedSectors, builtin12.DefaultHamtBitwidth) +} + +func (s *state12) PrecommitsMapBitWidth() int { + + return builtin12.DefaultHamtBitwidth + +} + +func (s *state12) PrecommitsMapHashFunction() func(input []byte) []byte { + + return func(input []byte) []byte { + res := sha256.Sum256(input) + return res[:] + } + +} + +func (s *state12) DecodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreCommitOnChainInfo, error) { + var sp miner12.SectorPreCommitOnChainInfo + err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw)) + if err != nil { + return SectorPreCommitOnChainInfo{}, err + } + + return fromV12SectorPreCommitOnChainInfo(sp), nil +} + +func (s *state12) DecodeSectorPreCommitOnChainInfoToV8(val *cbg.Deferred) (minertypesv8.SectorPreCommitOnChainInfo, error) { + + return minertypesv8.SectorPreCommitOnChainInfo{}, fmt.Errorf("unsupported in actors v9") + +} + +func (s *state12) ForEachPrecommittedSectorV8(cb func(minertypesv8.SectorPreCommitOnChainInfo) error) error { + + return fmt.Errorf("unsupported for actors v9") + +} + +func (s *state12) EraseAllUnproven() error { + + dls, err := s.State.LoadDeadlines(s.store) + if err != nil { + return err + } + + err = dls.ForEach(s.store, func(dindx uint64, dl *miner12.Deadline) error { + ps, err := dl.PartitionsArray(s.store) + if err != nil { + return err + } + + var part miner12.Partition + err = ps.ForEach(&part, func(pindx int64) error { + _ = part.ActivateUnproven() + err = ps.Set(uint64(pindx), &part) + return nil + }) + + if err != nil { + return err + } + + dl.Partitions, err = ps.Root() + if err != nil { + return err + } + + return dls.UpdateDeadline(s.store, dindx, dl) + }) + if err != nil { + return err + } + + return s.State.SaveDeadlines(s.store, dls) + +} + +func (d *deadline12) LoadPartition(idx uint64) (Partition, error) { + p, err := d.Deadline.LoadPartition(d.store, idx) + if err != nil { + return nil, err + } + return &partition12{*p, d.store}, nil +} + +func (d *deadline12) ForEachPartition(cb func(uint64, Partition) error) error { + ps, err := d.Deadline.PartitionsArray(d.store) + if err != nil { + return err + } + var part miner12.Partition + return ps.ForEach(&part, func(i int64) error { + return cb(uint64(i), &partition12{part, d.store}) + }) +} + +func (d *deadline12) PartitionsChanged(other Deadline) (bool, error) { + other12, ok := other.(*deadline12) + if !ok { + // treat an upgrade as a change, always + return true, nil + } + + return !d.Deadline.Partitions.Equals(other12.Deadline.Partitions), nil +} + +func (d *deadline12) PartitionsPoSted() (bitfield.BitField, error) { + return d.Deadline.PartitionsPoSted, nil +} + +func (d *deadline12) DisputableProofCount() (uint64, error) { + + ops, err := d.OptimisticProofsSnapshotArray(d.store) + if err != nil { + return 0, err + } + + return ops.Length(), nil + +} + +func (p *partition12) AllSectors() (bitfield.BitField, error) { + return p.Partition.Sectors, nil +} + +func (p *partition12) FaultySectors() (bitfield.BitField, error) { + return p.Partition.Faults, nil +} + +func (p *partition12) RecoveringSectors() (bitfield.BitField, error) { + return p.Partition.Recoveries, nil +} + +func (p *partition12) UnprovenSectors() (bitfield.BitField, error) { + return p.Partition.Unproven, nil +} + +func fromV12SectorOnChainInfo(v12 miner12.SectorOnChainInfo) SectorOnChainInfo { + info := SectorOnChainInfo{ + SectorNumber: v12.SectorNumber, + SealProof: v12.SealProof, + SealedCID: v12.SealedCID, + DealIDs: v12.DealIDs, + Activation: v12.Activation, + Expiration: v12.Expiration, + DealWeight: v12.DealWeight, + VerifiedDealWeight: v12.VerifiedDealWeight, + InitialPledge: v12.InitialPledge, + ExpectedDayReward: v12.ExpectedDayReward, + ExpectedStoragePledge: v12.ExpectedStoragePledge, + + SectorKeyCID: v12.SectorKeyCID, + } + return info +} + +func fromV12SectorPreCommitOnChainInfo(v12 miner12.SectorPreCommitOnChainInfo) SectorPreCommitOnChainInfo { + ret := SectorPreCommitOnChainInfo{ + Info: SectorPreCommitInfo{ + SealProof: v12.Info.SealProof, + SectorNumber: v12.Info.SectorNumber, + SealedCID: v12.Info.SealedCID, + SealRandEpoch: v12.Info.SealRandEpoch, + DealIDs: v12.Info.DealIDs, + Expiration: v12.Info.Expiration, + UnsealedCid: nil, + }, + PreCommitDeposit: v12.PreCommitDeposit, + PreCommitEpoch: v12.PreCommitEpoch, + } + + ret.Info.UnsealedCid = v12.Info.UnsealedCid + + return ret +} + +func (s *state12) GetState() interface{} { + return &s.State +} + +func (s *state12) SectorsAmtBitwidth() int { + return miner12.SectorsAmtBitwidth +} + +func (s *state12) ActorKey() string { + return actors.MinerKey +} + +func (s *state12) ActorVersion() actors.Version { + return actors.Version12 +} + +func (s *state12) 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/v13.go b/chain/actors/builtin/miner/v13.go new file mode 100644 index 000000000..62822d8ab --- /dev/null +++ b/chain/actors/builtin/miner/v13.go @@ -0,0 +1,623 @@ +// Code generated by: `make actors-gen`. DO NOT EDIT. +package miner + +import ( + "bytes" + "errors" + "fmt" + + "github.com/filecoin-project/go-bitfield" + rle "github.com/filecoin-project/go-bitfield/rle" + "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/go-state-types/dline" + "github.com/filecoin-project/lily/chain/actors" + "github.com/ipfs/go-cid" + cbg "github.com/whyrusleeping/cbor-gen" + "golang.org/x/xerrors" + + minertypesv8 "github.com/filecoin-project/go-state-types/builtin/v8/miner" + "github.com/filecoin-project/lotus/chain/actors/adt" + + "crypto/sha256" + + builtin13 "github.com/filecoin-project/go-state-types/builtin" + miner13 "github.com/filecoin-project/go-state-types/builtin/v13/miner" + adt13 "github.com/filecoin-project/go-state-types/builtin/v13/util/adt" +) + +var _ State = (*state13)(nil) + +func load13(store adt.Store, root cid.Cid) (State, error) { + out := state13{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make13(store adt.Store) (State, error) { + out := state13{store: store} + out.State = miner13.State{} + return &out, nil +} + +type state13 struct { + miner13.State + store adt.Store +} + +type deadline13 struct { + miner13.Deadline + store adt.Store +} + +type partition13 struct { + miner13.Partition + store adt.Store +} + +func (s *state13) AvailableBalance(bal abi.TokenAmount) (available abi.TokenAmount, err error) { + defer func() { + if r := recover(); r != nil { + err = xerrors.Errorf("failed to get available balance: %w", r) + available = abi.NewTokenAmount(0) + } + }() + // this panics if the miner doesnt have enough funds to cover their locked pledge + available, err = s.GetAvailableBalance(bal) + return available, err +} + +func (s *state13) VestedFunds(epoch abi.ChainEpoch) (abi.TokenAmount, error) { + return s.CheckVestedFunds(s.store, epoch) +} + +func (s *state13) LockedFunds() (LockedFunds, error) { + return LockedFunds{ + VestingFunds: s.State.LockedFunds, + InitialPledgeRequirement: s.State.InitialPledge, + PreCommitDeposits: s.State.PreCommitDeposits, + }, nil +} + +func (s *state13) FeeDebt() (abi.TokenAmount, error) { + return s.State.FeeDebt, nil +} + +func (s *state13) InitialPledge() (abi.TokenAmount, error) { + return s.State.InitialPledge, nil +} + +func (s *state13) PreCommitDeposits() (abi.TokenAmount, error) { + return s.State.PreCommitDeposits, nil +} + +func (s *state13) GetSector(num abi.SectorNumber) (*SectorOnChainInfo, error) { + info, ok, err := s.State.GetSector(s.store, num) + if !ok || err != nil { + return nil, err + } + + ret := fromV13SectorOnChainInfo(*info) + return &ret, nil +} + +func (s *state13) FindSector(num abi.SectorNumber) (*SectorLocation, error) { + dlIdx, partIdx, err := s.State.FindSector(s.store, num) + if err != nil { + return nil, err + } + return &SectorLocation{ + Deadline: dlIdx, + Partition: partIdx, + }, nil +} + +func (s *state13) NumLiveSectors() (uint64, error) { + dls, err := s.State.LoadDeadlines(s.store) + if err != nil { + return 0, err + } + var total uint64 + if err := dls.ForEach(s.store, func(dlIdx uint64, dl *miner13.Deadline) error { + total += dl.LiveSectors + return nil + }); err != nil { + return 0, err + } + return total, nil +} + +// GetSectorExpiration returns the effective expiration of the given sector. +// +// If the sector does not expire early, the Early expiration field is 0. +func (s *state13) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, error) { + dls, err := s.State.LoadDeadlines(s.store) + if err != nil { + return nil, err + } + // NOTE: this can be optimized significantly. + // 1. If the sector is non-faulty, it will expire on-time (can be + // learned from the sector info). + // 2. If it's faulty, it will expire early within the first 42 entries + // of the expiration queue. + + stopErr := errors.New("stop") + out := SectorExpiration{} + err = dls.ForEach(s.store, func(dlIdx uint64, dl *miner13.Deadline) error { + partitions, err := dl.PartitionsArray(s.store) + if err != nil { + return err + } + quant := s.State.QuantSpecForDeadline(dlIdx) + var part miner13.Partition + return partitions.ForEach(&part, func(partIdx int64) error { + if found, err := part.Sectors.IsSet(uint64(num)); err != nil { + return err + } else if !found { + return nil + } + if found, err := part.Terminated.IsSet(uint64(num)); err != nil { + return err + } else if found { + // already terminated + return stopErr + } + + q, err := miner13.LoadExpirationQueue(s.store, part.ExpirationsEpochs, quant, miner13.PartitionExpirationAmtBitwidth) + if err != nil { + return err + } + var exp miner13.ExpirationSet + return q.ForEach(&exp, func(epoch int64) error { + if early, err := exp.EarlySectors.IsSet(uint64(num)); err != nil { + return err + } else if early { + out.Early = abi.ChainEpoch(epoch) + return nil + } + if onTime, err := exp.OnTimeSectors.IsSet(uint64(num)); err != nil { + return err + } else if onTime { + out.OnTime = abi.ChainEpoch(epoch) + return stopErr + } + return nil + }) + }) + }) + if err == stopErr { + err = nil + } + if err != nil { + return nil, err + } + if out.Early == 0 && out.OnTime == 0 { + return nil, xerrors.Errorf("failed to find sector %d", num) + } + return &out, nil +} + +func (s *state13) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOnChainInfo, error) { + info, ok, err := s.State.GetPrecommittedSector(s.store, num) + if !ok || err != nil { + return nil, err + } + + ret := fromV13SectorPreCommitOnChainInfo(*info) + + return &ret, nil +} + +func (s *state13) ForEachPrecommittedSector(cb func(SectorPreCommitOnChainInfo) error) error { + precommitted, err := adt13.AsMap(s.store, s.State.PreCommittedSectors, builtin13.DefaultHamtBitwidth) + if err != nil { + return err + } + + var info miner13.SectorPreCommitOnChainInfo + if err := precommitted.ForEach(&info, func(_ string) error { + return cb(fromV13SectorPreCommitOnChainInfo(info)) + }); err != nil { + return err + } + + return nil +} + +func (s *state13) LoadSectors(snos *bitfield.BitField) ([]*SectorOnChainInfo, error) { + sectors, err := miner13.LoadSectors(s.store, s.State.Sectors) + if err != nil { + return nil, err + } + + // If no sector numbers are specified, load all. + if snos == nil { + infos := make([]*SectorOnChainInfo, 0, sectors.Length()) + var info13 miner13.SectorOnChainInfo + if err := sectors.ForEach(&info13, func(_ int64) error { + info := fromV13SectorOnChainInfo(info13) + infos = append(infos, &info) + return nil + }); err != nil { + return nil, err + } + return infos, nil + } + + // Otherwise, load selected. + infos13, err := sectors.Load(*snos) + if err != nil { + return nil, err + } + infos := make([]*SectorOnChainInfo, len(infos13)) + for i, info13 := range infos13 { + info := fromV13SectorOnChainInfo(*info13) + infos[i] = &info + } + return infos, nil +} + +func (s *state13) loadAllocatedSectorNumbers() (bitfield.BitField, error) { + var allocatedSectors bitfield.BitField + err := s.store.Get(s.store.Context(), s.State.AllocatedSectors, &allocatedSectors) + return allocatedSectors, err +} + +func (s *state13) IsAllocated(num abi.SectorNumber) (bool, error) { + allocatedSectors, err := s.loadAllocatedSectorNumbers() + if err != nil { + return false, err + } + + return allocatedSectors.IsSet(uint64(num)) +} + +func (s *state13) GetProvingPeriodStart() (abi.ChainEpoch, error) { + return s.State.ProvingPeriodStart, nil +} + +func (s *state13) UnallocatedSectorNumbers(count int) ([]abi.SectorNumber, error) { + allocatedSectors, err := s.loadAllocatedSectorNumbers() + if err != nil { + return nil, err + } + + allocatedRuns, err := allocatedSectors.RunIterator() + if err != nil { + return nil, err + } + + unallocatedRuns, err := rle.Subtract( + &rle.RunSliceIterator{Runs: []rle.Run{{Val: true, Len: abi.MaxSectorNumber}}}, + allocatedRuns, + ) + if err != nil { + return nil, err + } + + iter, err := rle.BitsFromRuns(unallocatedRuns) + if err != nil { + return nil, err + } + + sectors := make([]abi.SectorNumber, 0, count) + for iter.HasNext() && len(sectors) < count { + nextNo, err := iter.Next() + if err != nil { + return nil, err + } + sectors = append(sectors, abi.SectorNumber(nextNo)) + } + + return sectors, nil +} + +func (s *state13) GetAllocatedSectors() (*bitfield.BitField, error) { + var allocatedSectors bitfield.BitField + if err := s.store.Get(s.store.Context(), s.State.AllocatedSectors, &allocatedSectors); err != nil { + return nil, err + } + + return &allocatedSectors, nil +} + +func (s *state13) LoadDeadline(idx uint64) (Deadline, error) { + dls, err := s.State.LoadDeadlines(s.store) + if err != nil { + return nil, err + } + dl, err := dls.LoadDeadline(s.store, idx) + if err != nil { + return nil, err + } + return &deadline13{*dl, s.store}, nil +} + +func (s *state13) ForEachDeadline(cb func(uint64, Deadline) error) error { + dls, err := s.State.LoadDeadlines(s.store) + if err != nil { + return err + } + return dls.ForEach(s.store, func(i uint64, dl *miner13.Deadline) error { + return cb(i, &deadline13{*dl, s.store}) + }) +} + +func (s *state13) NumDeadlines() (uint64, error) { + return miner13.WPoStPeriodDeadlines, nil +} + +func (s *state13) DeadlinesChanged(other State) (bool, error) { + other13, ok := other.(*state13) + if !ok { + // treat an upgrade as a change, always + return true, nil + } + + return !s.State.Deadlines.Equals(other13.Deadlines), nil +} + +func (s *state13) MinerInfoChanged(other State) (bool, error) { + other0, ok := other.(*state13) + if !ok { + // treat an upgrade as a change, always + return true, nil + } + return !s.State.Info.Equals(other0.State.Info), nil +} + +func (s *state13) Info() (MinerInfo, error) { + info, err := s.State.GetInfo(s.store) + if err != nil { + return MinerInfo{}, err + } + + mi := MinerInfo{ + Owner: info.Owner, + Worker: info.Worker, + ControlAddresses: info.ControlAddresses, + + PendingWorkerKey: (*WorkerKeyChange)(info.PendingWorkerKey), + + PeerId: info.PeerId, + Multiaddrs: info.Multiaddrs, + WindowPoStProofType: info.WindowPoStProofType, + SectorSize: info.SectorSize, + WindowPoStPartitionSectors: info.WindowPoStPartitionSectors, + ConsensusFaultElapsed: info.ConsensusFaultElapsed, + + Beneficiary: info.Beneficiary, + BeneficiaryTerm: BeneficiaryTerm(info.BeneficiaryTerm), + PendingBeneficiaryTerm: (*PendingBeneficiaryChange)(info.PendingBeneficiaryTerm), + } + + return mi, nil +} + +func (s *state13) DeadlineInfo(epoch abi.ChainEpoch) (*dline.Info, error) { + return s.State.RecordedDeadlineInfo(epoch), nil +} + +func (s *state13) DeadlineCronActive() (bool, error) { + return s.State.DeadlineCronActive, nil +} + +func (s *state13) SectorsArray() (adt.Array, error) { + return adt13.AsArray(s.store, s.Sectors, miner13.SectorsAmtBitwidth) +} + +func (s *state13) DecodeSectorOnChainInfo(val *cbg.Deferred) (SectorOnChainInfo, error) { + var si miner13.SectorOnChainInfo + err := si.UnmarshalCBOR(bytes.NewReader(val.Raw)) + if err != nil { + return SectorOnChainInfo{}, err + } + + return fromV13SectorOnChainInfo(si), nil +} + +func (s *state13) PrecommitsMap() (adt.Map, error) { + return adt13.AsMap(s.store, s.PreCommittedSectors, builtin13.DefaultHamtBitwidth) +} + +func (s *state13) PrecommitsMapBitWidth() int { + + return builtin13.DefaultHamtBitwidth + +} + +func (s *state13) PrecommitsMapHashFunction() func(input []byte) []byte { + + return func(input []byte) []byte { + res := sha256.Sum256(input) + return res[:] + } + +} + +func (s *state13) DecodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreCommitOnChainInfo, error) { + var sp miner13.SectorPreCommitOnChainInfo + err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw)) + if err != nil { + return SectorPreCommitOnChainInfo{}, err + } + + return fromV13SectorPreCommitOnChainInfo(sp), nil +} + +func (s *state13) DecodeSectorPreCommitOnChainInfoToV8(val *cbg.Deferred) (minertypesv8.SectorPreCommitOnChainInfo, error) { + + return minertypesv8.SectorPreCommitOnChainInfo{}, fmt.Errorf("unsupported in actors v9") + +} + +func (s *state13) ForEachPrecommittedSectorV8(cb func(minertypesv8.SectorPreCommitOnChainInfo) error) error { + + return fmt.Errorf("unsupported for actors v9") + +} + +func (s *state13) EraseAllUnproven() error { + + dls, err := s.State.LoadDeadlines(s.store) + if err != nil { + return err + } + + err = dls.ForEach(s.store, func(dindx uint64, dl *miner13.Deadline) error { + ps, err := dl.PartitionsArray(s.store) + if err != nil { + return err + } + + var part miner13.Partition + err = ps.ForEach(&part, func(pindx int64) error { + _ = part.ActivateUnproven() + err = ps.Set(uint64(pindx), &part) + return nil + }) + + if err != nil { + return err + } + + dl.Partitions, err = ps.Root() + if err != nil { + return err + } + + return dls.UpdateDeadline(s.store, dindx, dl) + }) + if err != nil { + return err + } + + return s.State.SaveDeadlines(s.store, dls) + +} + +func (d *deadline13) LoadPartition(idx uint64) (Partition, error) { + p, err := d.Deadline.LoadPartition(d.store, idx) + if err != nil { + return nil, err + } + return &partition13{*p, d.store}, nil +} + +func (d *deadline13) ForEachPartition(cb func(uint64, Partition) error) error { + ps, err := d.Deadline.PartitionsArray(d.store) + if err != nil { + return err + } + var part miner13.Partition + return ps.ForEach(&part, func(i int64) error { + return cb(uint64(i), &partition13{part, d.store}) + }) +} + +func (d *deadline13) PartitionsChanged(other Deadline) (bool, error) { + other13, ok := other.(*deadline13) + if !ok { + // treat an upgrade as a change, always + return true, nil + } + + return !d.Deadline.Partitions.Equals(other13.Deadline.Partitions), nil +} + +func (d *deadline13) PartitionsPoSted() (bitfield.BitField, error) { + return d.Deadline.PartitionsPoSted, nil +} + +func (d *deadline13) DisputableProofCount() (uint64, error) { + + ops, err := d.OptimisticProofsSnapshotArray(d.store) + if err != nil { + return 0, err + } + + return ops.Length(), nil + +} + +func (p *partition13) AllSectors() (bitfield.BitField, error) { + return p.Partition.Sectors, nil +} + +func (p *partition13) FaultySectors() (bitfield.BitField, error) { + return p.Partition.Faults, nil +} + +func (p *partition13) RecoveringSectors() (bitfield.BitField, error) { + return p.Partition.Recoveries, nil +} + +func (p *partition13) UnprovenSectors() (bitfield.BitField, error) { + return p.Partition.Unproven, nil +} + +func fromV13SectorOnChainInfo(v13 miner13.SectorOnChainInfo) SectorOnChainInfo { + info := SectorOnChainInfo{ + SectorNumber: v13.SectorNumber, + SealProof: v13.SealProof, + SealedCID: v13.SealedCID, + DealIDs: v13.DealIDs, + Activation: v13.Activation, + Expiration: v13.Expiration, + DealWeight: v13.DealWeight, + VerifiedDealWeight: v13.VerifiedDealWeight, + InitialPledge: v13.InitialPledge, + ExpectedDayReward: v13.ExpectedDayReward, + ExpectedStoragePledge: v13.ExpectedStoragePledge, + + SectorKeyCID: v13.SectorKeyCID, + } + return info +} + +func fromV13SectorPreCommitOnChainInfo(v13 miner13.SectorPreCommitOnChainInfo) SectorPreCommitOnChainInfo { + ret := SectorPreCommitOnChainInfo{ + Info: SectorPreCommitInfo{ + SealProof: v13.Info.SealProof, + SectorNumber: v13.Info.SectorNumber, + SealedCID: v13.Info.SealedCID, + SealRandEpoch: v13.Info.SealRandEpoch, + DealIDs: v13.Info.DealIDs, + Expiration: v13.Info.Expiration, + UnsealedCid: nil, + }, + PreCommitDeposit: v13.PreCommitDeposit, + PreCommitEpoch: v13.PreCommitEpoch, + } + + ret.Info.UnsealedCid = v13.Info.UnsealedCid + + return ret +} + +func (s *state13) GetState() interface{} { + return &s.State +} + +func (s *state13) SectorsAmtBitwidth() int { + return miner13.SectorsAmtBitwidth +} + +func (s *state13) ActorKey() string { + return actors.MinerKey +} + +func (s *state13) ActorVersion() actors.Version { + return actors.Version13 +} + +func (s *state13) 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/multisig.go b/chain/actors/builtin/multisig/multisig.go index 961be66f2..52d1d82ff 100644 --- a/chain/actors/builtin/multisig/multisig.go +++ b/chain/actors/builtin/multisig/multisig.go @@ -12,7 +12,7 @@ import ( "github.com/filecoin-project/go-state-types/cbor" "github.com/ipfs/go-cid" - msig11 "github.com/filecoin-project/go-state-types/builtin/v11/multisig" + msig13 "github.com/filecoin-project/go-state-types/builtin/v13/multisig" builtin0 "github.com/filecoin-project/specs-actors/actors/builtin" @@ -56,6 +56,12 @@ func Load(store adt.Store, act *types.Actor) (State, error) { case actors.Version11: return load11(store, act.Head) + case actors.Version12: + return load12(store, act.Head) + + case actors.Version13: + return load13(store, act.Head) + } } @@ -110,19 +116,19 @@ type State interface { decodeTransaction(val *cbg.Deferred) (Transaction, error) } -type Transaction = msig11.Transaction +type Transaction = msig13.Transaction var Methods = builtintypes.MethodsMultisig // these types are the same between v0 and v6 -type ProposalHashData = msig11.ProposalHashData -type ProposeReturn = msig11.ProposeReturn -type ProposeParams = msig11.ProposeParams -type ApproveReturn = msig11.ApproveReturn -type TxnIDParams = msig11.TxnIDParams +type ProposalHashData = msig13.ProposalHashData +type ProposeReturn = msig13.ProposeReturn +type ProposeParams = msig13.ProposeParams +type ApproveReturn = msig13.ApproveReturn +type TxnIDParams = msig13.TxnIDParams func txnParams(id uint64, data *ProposalHashData) ([]byte, error) { - params := msig11.TxnIDParams{ID: msig11.TxnID(id)} + params := msig13.TxnIDParams{ID: msig13.TxnID(id)} if data != nil { if data.Requester.Protocol() != address.ID { return nil, fmt.Errorf("proposer address must be an ID address, was %s", data.Requester) @@ -157,6 +163,8 @@ func AllCodes() []cid.Cid { (&state9{}).Code(), (&state10{}).Code(), (&state11{}).Code(), + (&state12{}).Code(), + (&state13{}).Code(), } } @@ -173,5 +181,7 @@ func VersionCodes() map[actors.Version]cid.Cid { actors.Version9: (&state9{}).Code(), actors.Version10: (&state10{}).Code(), actors.Version11: (&state11{}).Code(), + actors.Version12: (&state12{}).Code(), + actors.Version13: (&state13{}).Code(), } } diff --git a/chain/actors/builtin/multisig/v12.go b/chain/actors/builtin/multisig/v12.go new file mode 100644 index 000000000..ecc3825d1 --- /dev/null +++ b/chain/actors/builtin/multisig/v12.go @@ -0,0 +1,130 @@ +// Code generated by: `make actors-gen`. DO NOT EDIT. +package multisig + +import ( + "bytes" + "encoding/binary" + "fmt" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/lily/chain/actors" + "github.com/ipfs/go-cid" + cbg "github.com/whyrusleeping/cbor-gen" + + "github.com/filecoin-project/lily/chain/actors/adt" + + "crypto/sha256" + + builtin12 "github.com/filecoin-project/go-state-types/builtin" + msig12 "github.com/filecoin-project/go-state-types/builtin/v12/multisig" + adt12 "github.com/filecoin-project/go-state-types/builtin/v12/util/adt" +) + +var _ State = (*state12)(nil) + +func load12(store adt.Store, root cid.Cid) (State, error) { + out := state12{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +type state12 struct { + msig12.State + store adt.Store +} + +func (s *state12) LockedBalance(currEpoch abi.ChainEpoch) (abi.TokenAmount, error) { + return s.State.AmountLocked(currEpoch - s.State.StartEpoch), nil +} + +func (s *state12) StartEpoch() (abi.ChainEpoch, error) { + return s.State.StartEpoch, nil +} + +func (s *state12) UnlockDuration() (abi.ChainEpoch, error) { + return s.State.UnlockDuration, nil +} + +func (s *state12) InitialBalance() (abi.TokenAmount, error) { + return s.State.InitialBalance, nil +} + +func (s *state12) Threshold() (uint64, error) { + return s.State.NumApprovalsThreshold, nil +} + +func (s *state12) Signers() ([]address.Address, error) { + return s.State.Signers, nil +} + +func (s *state12) ForEachPendingTxn(cb func(id int64, txn Transaction) error) error { + arr, err := adt12.AsMap(s.store, s.State.PendingTxns, builtin12.DefaultHamtBitwidth) + if err != nil { + return err + } + var out msig12.Transaction + return arr.ForEach(&out, func(key string) error { + txid, n := binary.Varint([]byte(key)) + if n <= 0 { + return fmt.Errorf("invalid pending transaction key: %v", key) + } + return cb(txid, (Transaction)(out)) //nolint:unconvert + }) +} + +func (s *state12) PendingTxnChanged(other State) (bool, error) { + other12, ok := other.(*state12) + if !ok { + // treat an upgrade as a change, always + return true, nil + } + return !s.State.PendingTxns.Equals(other12.PendingTxns), nil +} + +func (s *state12) PendingTransactionsMap() (adt.Map, error) { + return adt12.AsMap(s.store, s.PendingTxns, builtin12.DefaultHamtBitwidth) +} + +func (s *state12) PendingTransactionsMapBitWidth() int { + + return builtin12.DefaultHamtBitwidth + +} + +func (s *state12) PendingTransactionsMapHashFunction() func(input []byte) []byte { + + return func(input []byte) []byte { + res := sha256.Sum256(input) + return res[:] + } + +} + +func (s *state12) decodeTransaction(val *cbg.Deferred) (Transaction, error) { + var tx msig12.Transaction + if err := tx.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { + return Transaction{}, err + } + return Transaction(tx), nil +} + +func (s *state12) ActorKey() string { + return actors.MultisigKey +} + +func (s *state12) ActorVersion() actors.Version { + return actors.Version12 +} + +func (s *state12) 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/v13.go b/chain/actors/builtin/multisig/v13.go new file mode 100644 index 000000000..5d70401ce --- /dev/null +++ b/chain/actors/builtin/multisig/v13.go @@ -0,0 +1,130 @@ +// Code generated by: `make actors-gen`. DO NOT EDIT. +package multisig + +import ( + "bytes" + "encoding/binary" + "fmt" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/lily/chain/actors" + "github.com/ipfs/go-cid" + cbg "github.com/whyrusleeping/cbor-gen" + + "github.com/filecoin-project/lily/chain/actors/adt" + + "crypto/sha256" + + builtin13 "github.com/filecoin-project/go-state-types/builtin" + msig13 "github.com/filecoin-project/go-state-types/builtin/v13/multisig" + adt13 "github.com/filecoin-project/go-state-types/builtin/v13/util/adt" +) + +var _ State = (*state13)(nil) + +func load13(store adt.Store, root cid.Cid) (State, error) { + out := state13{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +type state13 struct { + msig13.State + store adt.Store +} + +func (s *state13) LockedBalance(currEpoch abi.ChainEpoch) (abi.TokenAmount, error) { + return s.State.AmountLocked(currEpoch - s.State.StartEpoch), nil +} + +func (s *state13) StartEpoch() (abi.ChainEpoch, error) { + return s.State.StartEpoch, nil +} + +func (s *state13) UnlockDuration() (abi.ChainEpoch, error) { + return s.State.UnlockDuration, nil +} + +func (s *state13) InitialBalance() (abi.TokenAmount, error) { + return s.State.InitialBalance, nil +} + +func (s *state13) Threshold() (uint64, error) { + return s.State.NumApprovalsThreshold, nil +} + +func (s *state13) Signers() ([]address.Address, error) { + return s.State.Signers, nil +} + +func (s *state13) ForEachPendingTxn(cb func(id int64, txn Transaction) error) error { + arr, err := adt13.AsMap(s.store, s.State.PendingTxns, builtin13.DefaultHamtBitwidth) + if err != nil { + return err + } + var out msig13.Transaction + return arr.ForEach(&out, func(key string) error { + txid, n := binary.Varint([]byte(key)) + if n <= 0 { + return fmt.Errorf("invalid pending transaction key: %v", key) + } + return cb(txid, (Transaction)(out)) //nolint:unconvert + }) +} + +func (s *state13) PendingTxnChanged(other State) (bool, error) { + other13, ok := other.(*state13) + if !ok { + // treat an upgrade as a change, always + return true, nil + } + return !s.State.PendingTxns.Equals(other13.PendingTxns), nil +} + +func (s *state13) PendingTransactionsMap() (adt.Map, error) { + return adt13.AsMap(s.store, s.PendingTxns, builtin13.DefaultHamtBitwidth) +} + +func (s *state13) PendingTransactionsMapBitWidth() int { + + return builtin13.DefaultHamtBitwidth + +} + +func (s *state13) PendingTransactionsMapHashFunction() func(input []byte) []byte { + + return func(input []byte) []byte { + res := sha256.Sum256(input) + return res[:] + } + +} + +func (s *state13) decodeTransaction(val *cbg.Deferred) (Transaction, error) { + var tx msig13.Transaction + if err := tx.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { + return Transaction{}, err + } + return Transaction(tx), nil +} + +func (s *state13) ActorKey() string { + return actors.MultisigKey +} + +func (s *state13) ActorVersion() actors.Version { + return actors.Version13 +} + +func (s *state13) 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/power.go b/chain/actors/builtin/power/power.go index 704e304a6..02c4dc265 100644 --- a/chain/actors/builtin/power/power.go +++ b/chain/actors/builtin/power/power.go @@ -32,14 +32,14 @@ import ( builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" - builtin11 "github.com/filecoin-project/go-state-types/builtin" + builtin13 "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/lily/chain/actors" ) var ( - Address = builtin11.StoragePowerActorAddr - Methods = builtin11.MethodsPower + Address = builtin13.StoragePowerActorAddr + Methods = builtin13.MethodsPower ) func Load(store adt.Store, act *types.Actor) (State, error) { @@ -62,6 +62,12 @@ func Load(store adt.Store, act *types.Actor) (State, error) { case actors.Version11: return load11(store, act.Head) + case actors.Version12: + return load12(store, act.Head) + + case actors.Version13: + return load13(store, act.Head) + } } @@ -149,6 +155,8 @@ func AllCodes() []cid.Cid { (&state9{}).Code(), (&state10{}).Code(), (&state11{}).Code(), + (&state12{}).Code(), + (&state13{}).Code(), } } @@ -165,5 +173,7 @@ func VersionCodes() map[actors.Version]cid.Cid { actors.Version9: (&state9{}).Code(), actors.Version10: (&state10{}).Code(), actors.Version11: (&state11{}).Code(), + actors.Version12: (&state12{}).Code(), + actors.Version13: (&state13{}).Code(), } } diff --git a/chain/actors/builtin/power/v12.go b/chain/actors/builtin/power/v12.go new file mode 100644 index 000000000..9a1264f57 --- /dev/null +++ b/chain/actors/builtin/power/v12.go @@ -0,0 +1,186 @@ +// Code generated by: `make actors-gen`. DO NOT EDIT. +package power + +import ( + "bytes" + "fmt" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/lily/chain/actors" + "github.com/ipfs/go-cid" + cbg "github.com/whyrusleeping/cbor-gen" + + "github.com/filecoin-project/lily/chain/actors/adt" + "github.com/filecoin-project/lily/chain/actors/builtin" + + "crypto/sha256" + + builtin12 "github.com/filecoin-project/go-state-types/builtin" + power12 "github.com/filecoin-project/go-state-types/builtin/v12/power" + adt12 "github.com/filecoin-project/go-state-types/builtin/v12/util/adt" +) + +var _ State = (*state12)(nil) + +func load12(store adt.Store, root cid.Cid) (State, error) { + out := state12{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +type state12 struct { + power12.State + store adt.Store +} + +func (s *state12) TotalLocked() (abi.TokenAmount, error) { + return s.TotalPledgeCollateral, nil +} + +func (s *state12) TotalPower() (Claim, error) { + return Claim{ + RawBytePower: s.TotalRawBytePower, + QualityAdjPower: s.TotalQualityAdjPower, + }, nil +} + +// Committed power to the network. Includes miners below the minimum threshold. +func (s *state12) TotalCommitted() (Claim, error) { + return Claim{ + RawBytePower: s.TotalBytesCommitted, + QualityAdjPower: s.TotalQABytesCommitted, + }, nil +} + +func (s *state12) MinerPower(addr address.Address) (Claim, bool, error) { + claims, err := s.ClaimsMap() + if err != nil { + return Claim{}, false, err + } + var claim power12.Claim + ok, err := claims.Get(abi.AddrKey(addr), &claim) + if err != nil { + return Claim{}, false, err + } + return Claim{ + RawBytePower: claim.RawBytePower, + QualityAdjPower: claim.QualityAdjPower, + }, ok, nil +} + +func (s *state12) MinerNominalPowerMeetsConsensusMinimum(a address.Address) (bool, error) { + return s.State.MinerNominalPowerMeetsConsensusMinimum(s.store, a) +} + +func (s *state12) TotalPowerSmoothed() (builtin.FilterEstimate, error) { + return builtin.FilterEstimate(s.State.ThisEpochQAPowerSmoothed), nil +} + +func (s *state12) MinerCounts() (uint64, uint64, error) { + return uint64(s.State.MinerAboveMinPowerCount), uint64(s.State.MinerCount), nil +} + +func (s *state12) ListAllMiners() ([]address.Address, error) { + claims, err := s.ClaimsMap() + if err != nil { + return nil, err + } + + var miners []address.Address + err = claims.ForEach(nil, func(k string) error { + a, err := address.NewFromBytes([]byte(k)) + if err != nil { + return err + } + miners = append(miners, a) + return nil + }) + if err != nil { + return nil, err + } + + return miners, nil +} + +func (s *state12) ForEachClaim(cb func(miner address.Address, claim Claim) error) error { + claims, err := s.ClaimsMap() + if err != nil { + return err + } + + var claim power12.Claim + return claims.ForEach(&claim, func(k string) error { + a, err := address.NewFromBytes([]byte(k)) + if err != nil { + return err + } + return cb(a, Claim{ + RawBytePower: claim.RawBytePower, + QualityAdjPower: claim.QualityAdjPower, + }) + }) +} + +func (s *state12) ClaimsChanged(other State) (bool, error) { + other12, ok := other.(*state12) + if !ok { + // treat an upgrade as a change, always + return true, nil + } + return !s.State.Claims.Equals(other12.State.Claims), nil +} + +func (s *state12) ClaimsMap() (adt.Map, error) { + return adt12.AsMap(s.store, s.Claims, builtin12.DefaultHamtBitwidth) +} + +func (s *state12) ClaimsMapBitWidth() int { + + return builtin12.DefaultHamtBitwidth + +} + +func (s *state12) ClaimsMapHashFunction() func(input []byte) []byte { + + return func(input []byte) []byte { + res := sha256.Sum256(input) + return res[:] + } + +} + +func (s *state12) decodeClaim(val *cbg.Deferred) (Claim, error) { + var ci power12.Claim + if err := ci.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { + return Claim{}, err + } + return fromV12Claim(ci), nil +} + +func fromV12Claim(v12 power12.Claim) Claim { + return Claim{ + RawBytePower: v12.RawBytePower, + QualityAdjPower: v12.QualityAdjPower, + } +} + +func (s *state12) ActorKey() string { + return actors.PowerKey +} + +func (s *state12) ActorVersion() actors.Version { + return actors.Version12 +} + +func (s *state12) 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/v13.go b/chain/actors/builtin/power/v13.go new file mode 100644 index 000000000..c8620a3d8 --- /dev/null +++ b/chain/actors/builtin/power/v13.go @@ -0,0 +1,186 @@ +// Code generated by: `make actors-gen`. DO NOT EDIT. +package power + +import ( + "bytes" + "fmt" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/lily/chain/actors" + "github.com/ipfs/go-cid" + cbg "github.com/whyrusleeping/cbor-gen" + + "github.com/filecoin-project/lily/chain/actors/adt" + "github.com/filecoin-project/lily/chain/actors/builtin" + + "crypto/sha256" + + builtin13 "github.com/filecoin-project/go-state-types/builtin" + power13 "github.com/filecoin-project/go-state-types/builtin/v13/power" + adt13 "github.com/filecoin-project/go-state-types/builtin/v13/util/adt" +) + +var _ State = (*state13)(nil) + +func load13(store adt.Store, root cid.Cid) (State, error) { + out := state13{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +type state13 struct { + power13.State + store adt.Store +} + +func (s *state13) TotalLocked() (abi.TokenAmount, error) { + return s.TotalPledgeCollateral, nil +} + +func (s *state13) TotalPower() (Claim, error) { + return Claim{ + RawBytePower: s.TotalRawBytePower, + QualityAdjPower: s.TotalQualityAdjPower, + }, nil +} + +// Committed power to the network. Includes miners below the minimum threshold. +func (s *state13) TotalCommitted() (Claim, error) { + return Claim{ + RawBytePower: s.TotalBytesCommitted, + QualityAdjPower: s.TotalQABytesCommitted, + }, nil +} + +func (s *state13) MinerPower(addr address.Address) (Claim, bool, error) { + claims, err := s.ClaimsMap() + if err != nil { + return Claim{}, false, err + } + var claim power13.Claim + ok, err := claims.Get(abi.AddrKey(addr), &claim) + if err != nil { + return Claim{}, false, err + } + return Claim{ + RawBytePower: claim.RawBytePower, + QualityAdjPower: claim.QualityAdjPower, + }, ok, nil +} + +func (s *state13) MinerNominalPowerMeetsConsensusMinimum(a address.Address) (bool, error) { + return s.State.MinerNominalPowerMeetsConsensusMinimum(s.store, a) +} + +func (s *state13) TotalPowerSmoothed() (builtin.FilterEstimate, error) { + return builtin.FilterEstimate(s.State.ThisEpochQAPowerSmoothed), nil +} + +func (s *state13) MinerCounts() (uint64, uint64, error) { + return uint64(s.State.MinerAboveMinPowerCount), uint64(s.State.MinerCount), nil +} + +func (s *state13) ListAllMiners() ([]address.Address, error) { + claims, err := s.ClaimsMap() + if err != nil { + return nil, err + } + + var miners []address.Address + err = claims.ForEach(nil, func(k string) error { + a, err := address.NewFromBytes([]byte(k)) + if err != nil { + return err + } + miners = append(miners, a) + return nil + }) + if err != nil { + return nil, err + } + + return miners, nil +} + +func (s *state13) ForEachClaim(cb func(miner address.Address, claim Claim) error) error { + claims, err := s.ClaimsMap() + if err != nil { + return err + } + + var claim power13.Claim + return claims.ForEach(&claim, func(k string) error { + a, err := address.NewFromBytes([]byte(k)) + if err != nil { + return err + } + return cb(a, Claim{ + RawBytePower: claim.RawBytePower, + QualityAdjPower: claim.QualityAdjPower, + }) + }) +} + +func (s *state13) ClaimsChanged(other State) (bool, error) { + other13, ok := other.(*state13) + if !ok { + // treat an upgrade as a change, always + return true, nil + } + return !s.State.Claims.Equals(other13.State.Claims), nil +} + +func (s *state13) ClaimsMap() (adt.Map, error) { + return adt13.AsMap(s.store, s.Claims, builtin13.DefaultHamtBitwidth) +} + +func (s *state13) ClaimsMapBitWidth() int { + + return builtin13.DefaultHamtBitwidth + +} + +func (s *state13) ClaimsMapHashFunction() func(input []byte) []byte { + + return func(input []byte) []byte { + res := sha256.Sum256(input) + return res[:] + } + +} + +func (s *state13) decodeClaim(val *cbg.Deferred) (Claim, error) { + var ci power13.Claim + if err := ci.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { + return Claim{}, err + } + return fromV13Claim(ci), nil +} + +func fromV13Claim(v13 power13.Claim) Claim { + return Claim{ + RawBytePower: v13.RawBytePower, + QualityAdjPower: v13.QualityAdjPower, + } +} + +func (s *state13) ActorKey() string { + return actors.PowerKey +} + +func (s *state13) ActorVersion() actors.Version { + return actors.Version13 +} + +func (s *state13) 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/reward.go b/chain/actors/builtin/reward/reward.go index 43ee33de1..846ec764d 100644 --- a/chain/actors/builtin/reward/reward.go +++ b/chain/actors/builtin/reward/reward.go @@ -23,7 +23,7 @@ import ( builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" - builtin11 "github.com/filecoin-project/go-state-types/builtin" + builtin13 "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/lotus/chain/types" @@ -35,8 +35,8 @@ import ( ) var ( - Address = builtin11.RewardActorAddr - Methods = builtin11.MethodsReward + Address = builtin13.RewardActorAddr + Methods = builtin13.MethodsReward ) func Load(store adt.Store, act *types.Actor) (State, error) { @@ -59,6 +59,12 @@ func Load(store adt.Store, act *types.Actor) (State, error) { case actors.Version11: return load11(store, act.Head) + case actors.Version12: + return load12(store, act.Head) + + case actors.Version13: + return load13(store, act.Head) + } } @@ -128,6 +134,8 @@ func AllCodes() []cid.Cid { (&state9{}).Code(), (&state10{}).Code(), (&state11{}).Code(), + (&state12{}).Code(), + (&state13{}).Code(), } } @@ -144,5 +152,7 @@ func VersionCodes() map[actors.Version]cid.Cid { actors.Version9: (&state9{}).Code(), actors.Version10: (&state10{}).Code(), actors.Version11: (&state11{}).Code(), + actors.Version12: (&state12{}).Code(), + actors.Version13: (&state13{}).Code(), } } diff --git a/chain/actors/builtin/reward/v12.go b/chain/actors/builtin/reward/v12.go new file mode 100644 index 000000000..479976e34 --- /dev/null +++ b/chain/actors/builtin/reward/v12.go @@ -0,0 +1,109 @@ +// Code generated by: `make actors-gen`. DO NOT EDIT. +package reward + +import ( + "fmt" + + "github.com/filecoin-project/go-state-types/abi" + "github.com/ipfs/go-cid" + + "github.com/filecoin-project/lily/chain/actors" + "github.com/filecoin-project/lily/chain/actors/adt" + "github.com/filecoin-project/lily/chain/actors/builtin" + + miner12 "github.com/filecoin-project/go-state-types/builtin/v12/miner" + reward12 "github.com/filecoin-project/go-state-types/builtin/v12/reward" + smoothing12 "github.com/filecoin-project/go-state-types/builtin/v12/util/smoothing" +) + +var _ State = (*state12)(nil) + +func load12(store adt.Store, root cid.Cid) (State, error) { + out := state12{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +type state12 struct { + reward12.State + store adt.Store +} + +func (s *state12) ThisEpochReward() (abi.TokenAmount, error) { + return s.State.ThisEpochReward, nil +} + +func (s *state12) ThisEpochRewardSmoothed() (builtin.FilterEstimate, error) { + + return builtin.FilterEstimate{ + PositionEstimate: s.State.ThisEpochRewardSmoothed.PositionEstimate, + VelocityEstimate: s.State.ThisEpochRewardSmoothed.VelocityEstimate, + }, nil + +} + +func (s *state12) ThisEpochBaselinePower() (abi.StoragePower, error) { + return s.State.ThisEpochBaselinePower, nil +} + +func (s *state12) TotalStoragePowerReward() (abi.TokenAmount, error) { + return s.State.TotalStoragePowerReward, nil +} + +func (s *state12) EffectiveBaselinePower() (abi.StoragePower, error) { + return s.State.EffectiveBaselinePower, nil +} + +func (s *state12) EffectiveNetworkTime() (abi.ChainEpoch, error) { + return s.State.EffectiveNetworkTime, nil +} + +func (s *state12) CumsumBaseline() (reward12.Spacetime, error) { + return s.State.CumsumBaseline, nil +} + +func (s *state12) CumsumRealized() (reward12.Spacetime, error) { + return s.State.CumsumRealized, nil +} + +func (s *state12) InitialPledgeForPower(qaPower abi.StoragePower, networkTotalPledge abi.TokenAmount, networkQAPower *builtin.FilterEstimate, circSupply abi.TokenAmount) (abi.TokenAmount, error) { + return miner12.InitialPledgeForPower( + qaPower, + s.State.ThisEpochBaselinePower, + s.State.ThisEpochRewardSmoothed, + smoothing12.FilterEstimate{ + PositionEstimate: networkQAPower.PositionEstimate, + VelocityEstimate: networkQAPower.VelocityEstimate, + }, + circSupply, + ), nil +} + +func (s *state12) PreCommitDepositForPower(networkQAPower builtin.FilterEstimate, sectorWeight abi.StoragePower) (abi.TokenAmount, error) { + return miner12.PreCommitDepositForPower(s.State.ThisEpochRewardSmoothed, + smoothing12.FilterEstimate{ + PositionEstimate: networkQAPower.PositionEstimate, + VelocityEstimate: networkQAPower.VelocityEstimate, + }, + sectorWeight), nil +} + +func (s *state12) ActorKey() string { + return actors.RewardKey +} + +func (s *state12) ActorVersion() actors.Version { + return actors.Version12 +} + +func (s *state12) 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/v13.go b/chain/actors/builtin/reward/v13.go new file mode 100644 index 000000000..fff886fed --- /dev/null +++ b/chain/actors/builtin/reward/v13.go @@ -0,0 +1,109 @@ +// Code generated by: `make actors-gen`. DO NOT EDIT. +package reward + +import ( + "fmt" + + "github.com/filecoin-project/go-state-types/abi" + "github.com/ipfs/go-cid" + + "github.com/filecoin-project/lily/chain/actors" + "github.com/filecoin-project/lily/chain/actors/adt" + "github.com/filecoin-project/lily/chain/actors/builtin" + + miner13 "github.com/filecoin-project/go-state-types/builtin/v13/miner" + reward13 "github.com/filecoin-project/go-state-types/builtin/v13/reward" + smoothing13 "github.com/filecoin-project/go-state-types/builtin/v13/util/smoothing" +) + +var _ State = (*state13)(nil) + +func load13(store adt.Store, root cid.Cid) (State, error) { + out := state13{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +type state13 struct { + reward13.State + store adt.Store +} + +func (s *state13) ThisEpochReward() (abi.TokenAmount, error) { + return s.State.ThisEpochReward, nil +} + +func (s *state13) ThisEpochRewardSmoothed() (builtin.FilterEstimate, error) { + + return builtin.FilterEstimate{ + PositionEstimate: s.State.ThisEpochRewardSmoothed.PositionEstimate, + VelocityEstimate: s.State.ThisEpochRewardSmoothed.VelocityEstimate, + }, nil + +} + +func (s *state13) ThisEpochBaselinePower() (abi.StoragePower, error) { + return s.State.ThisEpochBaselinePower, nil +} + +func (s *state13) TotalStoragePowerReward() (abi.TokenAmount, error) { + return s.State.TotalStoragePowerReward, nil +} + +func (s *state13) EffectiveBaselinePower() (abi.StoragePower, error) { + return s.State.EffectiveBaselinePower, nil +} + +func (s *state13) EffectiveNetworkTime() (abi.ChainEpoch, error) { + return s.State.EffectiveNetworkTime, nil +} + +func (s *state13) CumsumBaseline() (reward13.Spacetime, error) { + return s.State.CumsumBaseline, nil +} + +func (s *state13) CumsumRealized() (reward13.Spacetime, error) { + return s.State.CumsumRealized, nil +} + +func (s *state13) InitialPledgeForPower(qaPower abi.StoragePower, networkTotalPledge abi.TokenAmount, networkQAPower *builtin.FilterEstimate, circSupply abi.TokenAmount) (abi.TokenAmount, error) { + return miner13.InitialPledgeForPower( + qaPower, + s.State.ThisEpochBaselinePower, + s.State.ThisEpochRewardSmoothed, + smoothing13.FilterEstimate{ + PositionEstimate: networkQAPower.PositionEstimate, + VelocityEstimate: networkQAPower.VelocityEstimate, + }, + circSupply, + ), nil +} + +func (s *state13) PreCommitDepositForPower(networkQAPower builtin.FilterEstimate, sectorWeight abi.StoragePower) (abi.TokenAmount, error) { + return miner13.PreCommitDepositForPower(s.State.ThisEpochRewardSmoothed, + smoothing13.FilterEstimate{ + PositionEstimate: networkQAPower.PositionEstimate, + VelocityEstimate: networkQAPower.VelocityEstimate, + }, + sectorWeight), nil +} + +func (s *state13) ActorKey() string { + return actors.RewardKey +} + +func (s *state13) ActorVersion() actors.Version { + return actors.Version13 +} + +func (s *state13) 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/v12.go b/chain/actors/builtin/verifreg/v12.go new file mode 100644 index 000000000..07297d27a --- /dev/null +++ b/chain/actors/builtin/verifreg/v12.go @@ -0,0 +1,172 @@ +// Code generated by: `make actors-gen`. DO NOT EDIT. +package verifreg + +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/lily/chain/actors/adt" + + "crypto/sha256" + + builtin12 "github.com/filecoin-project/go-state-types/builtin" + adt12 "github.com/filecoin-project/go-state-types/builtin/v12/util/adt" + verifreg12 "github.com/filecoin-project/go-state-types/builtin/v12/verifreg" + + "github.com/filecoin-project/go-state-types/big" + + verifreg9 "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" + + "github.com/filecoin-project/lily/chain/actors" +) + +var _ State = (*state12)(nil) + +func load12(store adt.Store, root cid.Cid) (State, error) { + out := state12{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +type state12 struct { + verifreg12.State + store adt.Store +} + +func (s *state12) ActorKey() string { + return actors.VerifregKey +} + +func (s *state12) ActorVersion() actors.Version { + return actors.Version12 +} + +func (s *state12) 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 +} + +func (s *state12) VerifiedClientsMapBitWidth() int { + + return builtin12.DefaultHamtBitwidth + +} + +func (s *state12) VerifiedClientsMapHashFunction() func(input []byte) []byte { + + return func(input []byte) []byte { + res := sha256.Sum256(input) + return res[:] + } + +} + +func (s *state12) VerifiedClientsMap() (adt.Map, error) { + + return nil, fmt.Errorf("unsupported in actors v12") + +} + +func (s *state12) VerifiersMap() (adt.Map, error) { + return adt12.AsMap(s.store, s.Verifiers, builtin12.DefaultHamtBitwidth) +} + +func (s *state12) VerifiersMapBitWidth() int { + + return builtin12.DefaultHamtBitwidth + +} + +func (s *state12) VerifiersMapHashFunction() func(input []byte) []byte { + + return func(input []byte) []byte { + res := sha256.Sum256(input) + return res[:] + } + +} + +func (s *state12) RootKey() (address.Address, error) { + return s.State.RootKey, nil +} + +func (s *state12) VerifiedClientDataCap(addr address.Address) (bool, abi.StoragePower, error) { + + return false, big.Zero(), fmt.Errorf("unsupported in actors v12") + +} + +func (s *state12) VerifierDataCap(addr address.Address) (bool, abi.StoragePower, error) { + return getDataCap(s.store, actors.Version12, s.VerifiersMap, addr) +} + +func (s *state12) RemoveDataCapProposalID(verifier address.Address, client address.Address) (bool, uint64, error) { + return getRemoveDataCapProposalID(s.store, actors.Version12, s.removeDataCapProposalIDs, verifier, client) +} + +func (s *state12) ForEachVerifier(cb func(addr address.Address, dcap abi.StoragePower) error) error { + return forEachCap(s.store, actors.Version12, s.VerifiersMap, cb) +} + +func (s *state12) ForEachClient(cb func(addr address.Address, dcap abi.StoragePower) error) error { + + return fmt.Errorf("unsupported in actors v12") + +} + +func (s *state12) removeDataCapProposalIDs() (adt.Map, error) { + return adt12.AsMap(s.store, s.RemoveDataCapProposalIDs, builtin12.DefaultHamtBitwidth) +} + +func (s *state12) GetState() interface{} { + return &s.State +} + +func (s *state12) GetAllocation(clientIdAddr address.Address, allocationId verifreg9.AllocationId) (*Allocation, bool, error) { + + alloc, ok, err := s.FindAllocation(s.store, clientIdAddr, verifreg12.AllocationId(allocationId)) + return (*Allocation)(alloc), ok, err +} + +func (s *state12) GetAllocations(clientIdAddr address.Address) (map[AllocationId]Allocation, error) { + + v12Map, err := s.LoadAllocationsToMap(s.store, clientIdAddr) + + retMap := make(map[AllocationId]Allocation, len(v12Map)) + for k, v := range v12Map { + retMap[AllocationId(k)] = Allocation(v) + } + + return retMap, err + +} + +func (s *state12) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*Claim, bool, error) { + + claim, ok, err := s.FindClaim(s.store, providerIdAddr, verifreg12.ClaimId(claimId)) + return (*Claim)(claim), ok, err + +} + +func (s *state12) GetClaims(providerIdAddr address.Address) (map[ClaimId]Claim, error) { + + v12Map, err := s.LoadClaimsToMap(s.store, providerIdAddr) + + retMap := make(map[ClaimId]Claim, len(v12Map)) + for k, v := range v12Map { + retMap[ClaimId(k)] = Claim(v) + } + + return retMap, err + +} diff --git a/chain/actors/builtin/verifreg/v13.go b/chain/actors/builtin/verifreg/v13.go new file mode 100644 index 000000000..1675ebd4d --- /dev/null +++ b/chain/actors/builtin/verifreg/v13.go @@ -0,0 +1,172 @@ +// Code generated by: `make actors-gen`. DO NOT EDIT. +package verifreg + +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/lily/chain/actors/adt" + + "crypto/sha256" + + builtin13 "github.com/filecoin-project/go-state-types/builtin" + adt13 "github.com/filecoin-project/go-state-types/builtin/v13/util/adt" + verifreg13 "github.com/filecoin-project/go-state-types/builtin/v13/verifreg" + + "github.com/filecoin-project/go-state-types/big" + + verifreg9 "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" + + "github.com/filecoin-project/lily/chain/actors" +) + +var _ State = (*state13)(nil) + +func load13(store adt.Store, root cid.Cid) (State, error) { + out := state13{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +type state13 struct { + verifreg13.State + store adt.Store +} + +func (s *state13) ActorKey() string { + return actors.VerifregKey +} + +func (s *state13) ActorVersion() actors.Version { + return actors.Version13 +} + +func (s *state13) 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 +} + +func (s *state13) VerifiedClientsMapBitWidth() int { + + return builtin13.DefaultHamtBitwidth + +} + +func (s *state13) VerifiedClientsMapHashFunction() func(input []byte) []byte { + + return func(input []byte) []byte { + res := sha256.Sum256(input) + return res[:] + } + +} + +func (s *state13) VerifiedClientsMap() (adt.Map, error) { + + return nil, fmt.Errorf("unsupported in actors v13") + +} + +func (s *state13) VerifiersMap() (adt.Map, error) { + return adt13.AsMap(s.store, s.Verifiers, builtin13.DefaultHamtBitwidth) +} + +func (s *state13) VerifiersMapBitWidth() int { + + return builtin13.DefaultHamtBitwidth + +} + +func (s *state13) VerifiersMapHashFunction() func(input []byte) []byte { + + return func(input []byte) []byte { + res := sha256.Sum256(input) + return res[:] + } + +} + +func (s *state13) RootKey() (address.Address, error) { + return s.State.RootKey, nil +} + +func (s *state13) VerifiedClientDataCap(addr address.Address) (bool, abi.StoragePower, error) { + + return false, big.Zero(), fmt.Errorf("unsupported in actors v13") + +} + +func (s *state13) VerifierDataCap(addr address.Address) (bool, abi.StoragePower, error) { + return getDataCap(s.store, actors.Version13, s.VerifiersMap, addr) +} + +func (s *state13) RemoveDataCapProposalID(verifier address.Address, client address.Address) (bool, uint64, error) { + return getRemoveDataCapProposalID(s.store, actors.Version13, s.removeDataCapProposalIDs, verifier, client) +} + +func (s *state13) ForEachVerifier(cb func(addr address.Address, dcap abi.StoragePower) error) error { + return forEachCap(s.store, actors.Version13, s.VerifiersMap, cb) +} + +func (s *state13) ForEachClient(cb func(addr address.Address, dcap abi.StoragePower) error) error { + + return fmt.Errorf("unsupported in actors v13") + +} + +func (s *state13) removeDataCapProposalIDs() (adt.Map, error) { + return adt13.AsMap(s.store, s.RemoveDataCapProposalIDs, builtin13.DefaultHamtBitwidth) +} + +func (s *state13) GetState() interface{} { + return &s.State +} + +func (s *state13) GetAllocation(clientIdAddr address.Address, allocationId verifreg9.AllocationId) (*Allocation, bool, error) { + + alloc, ok, err := s.FindAllocation(s.store, clientIdAddr, verifreg13.AllocationId(allocationId)) + return (*Allocation)(alloc), ok, err +} + +func (s *state13) GetAllocations(clientIdAddr address.Address) (map[AllocationId]Allocation, error) { + + v13Map, err := s.LoadAllocationsToMap(s.store, clientIdAddr) + + retMap := make(map[AllocationId]Allocation, len(v13Map)) + for k, v := range v13Map { + retMap[AllocationId(k)] = Allocation(v) + } + + return retMap, err + +} + +func (s *state13) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*Claim, bool, error) { + + claim, ok, err := s.FindClaim(s.store, providerIdAddr, verifreg13.ClaimId(claimId)) + return (*Claim)(claim), ok, err + +} + +func (s *state13) GetClaims(providerIdAddr address.Address) (map[ClaimId]Claim, error) { + + v13Map, err := s.LoadClaimsToMap(s.store, providerIdAddr) + + retMap := make(map[ClaimId]Claim, len(v13Map)) + for k, v := range v13Map { + retMap[ClaimId(k)] = Claim(v) + } + + return retMap, err + +} diff --git a/chain/actors/builtin/verifreg/verifreg.go b/chain/actors/builtin/verifreg/verifreg.go index e7c961c2a..8d9a70346 100644 --- a/chain/actors/builtin/verifreg/verifreg.go +++ b/chain/actors/builtin/verifreg/verifreg.go @@ -24,7 +24,7 @@ import ( builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" - builtin11 "github.com/filecoin-project/go-state-types/builtin" + builtin13 "github.com/filecoin-project/go-state-types/builtin" verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" lotusactors "github.com/filecoin-project/lotus/chain/actors" @@ -35,8 +35,8 @@ import ( ) var ( - Address = builtin11.VerifiedRegistryActorAddr - Methods = builtin11.MethodsVerifiedRegistry + Address = builtin13.VerifiedRegistryActorAddr + Methods = builtin13.MethodsVerifiedRegistry ) func Load(store adt.Store, act *types.Actor) (State, error) { @@ -59,6 +59,12 @@ func Load(store adt.Store, act *types.Actor) (State, error) { case actors.Version11: return load11(store, act.Head) + case actors.Version12: + return load12(store, act.Head) + + case actors.Version13: + return load13(store, act.Head) + } } @@ -147,6 +153,8 @@ func AllCodes() []cid.Cid { (&state9{}).Code(), (&state10{}).Code(), (&state11{}).Code(), + (&state12{}).Code(), + (&state13{}).Code(), } } @@ -163,6 +171,8 @@ func VersionCodes() map[actors.Version]cid.Cid { actors.Version9: (&state9{}).Code(), actors.Version10: (&state10{}).Code(), actors.Version11: (&state11{}).Code(), + actors.Version12: (&state12{}).Code(), + actors.Version13: (&state13{}).Code(), } } diff --git a/go.mod b/go.mod index d577194c2..85a4f4e70 100644 --- a/go.mod +++ b/go.mod @@ -13,8 +13,8 @@ require ( github.com/filecoin-project/go-hamt-ipld/v3 v3.1.1-0.20220505191157-d7766f8628ec github.com/filecoin-project/go-jsonrpc v0.2.1 github.com/filecoin-project/go-paramfetch v0.0.4 - github.com/filecoin-project/go-state-types v0.10.0-rc2.0.20230213183937-7f1ede218b87 - github.com/filecoin-project/lotus v1.20.0-hyperspace-nv20 + github.com/filecoin-project/go-state-types v0.10.0-rc3.0.20230224225638-2fa7a438fd4a + github.com/filecoin-project/lotus v1.20.0-hyperspace-nv21-hotfix-01 github.com/filecoin-project/specs-actors v0.9.15 github.com/filecoin-project/specs-actors/v2 v2.3.6 github.com/filecoin-project/specs-actors/v3 v3.1.2 @@ -26,7 +26,7 @@ require ( github.com/go-pg/migrations/v8 v8.0.1 github.com/go-pg/pg/v10 v10.10.6 github.com/hashicorp/golang-lru v0.5.4 - github.com/ipfs/go-block-format v0.0.3 + github.com/ipfs/go-block-format v0.1.1 // indirect github.com/ipfs/go-cid v0.3.2 github.com/ipfs/go-fs-lock v0.0.7 github.com/ipfs/go-ipfs-blockstore v1.2.0 @@ -39,11 +39,11 @@ require ( github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 github.com/minio/sha256-simd v1.0.0 github.com/mitchellh/go-homedir v1.1.0 - github.com/multiformats/go-multiaddr v0.7.0 + github.com/multiformats/go-multiaddr v0.8.0 github.com/multiformats/go-multihash v0.2.1 github.com/prometheus/client_golang v1.13.0 github.com/raulk/clock v1.1.0 - github.com/stretchr/testify v1.8.0 + github.com/stretchr/testify v1.8.1 github.com/urfave/cli/v2 v2.16.3 github.com/whyrusleeping/cbor-gen v0.0.0-20221021053955-c138aae13722 go.opencensus.io v0.23.0 @@ -67,8 +67,9 @@ require ( github.com/hibiken/asynq v0.23.0 github.com/hibiken/asynq/x v0.0.0-20220413130846-5c723f597e01 github.com/ipfs/go-ipld-format v0.4.0 + github.com/ipfs/go-libipfs v0.4.1 github.com/jedib0t/go-pretty/v6 v6.2.7 - github.com/libp2p/go-libp2p v0.23.2 + github.com/libp2p/go-libp2p v0.23.4 github.com/multiformats/go-varint v0.0.6 go.opentelemetry.io/otel/trace v1.11.1 go.uber.org/atomic v1.10.0 @@ -129,7 +130,7 @@ require ( github.com/filecoin-project/go-ds-versioning v0.1.2 // indirect github.com/filecoin-project/go-fil-commcid v0.1.0 // indirect github.com/filecoin-project/go-fil-commp-hashhash v0.1.0 // indirect - github.com/filecoin-project/go-fil-markets v1.25.2 // indirect + github.com/filecoin-project/go-fil-markets v1.25.3 // indirect github.com/filecoin-project/go-hamt-ipld v0.1.5 // indirect github.com/filecoin-project/go-hamt-ipld/v2 v2.0.0 // indirect github.com/filecoin-project/go-legs v0.4.4 // indirect @@ -137,10 +138,8 @@ require ( github.com/filecoin-project/go-statemachine v1.0.2 // indirect github.com/filecoin-project/go-statestore v0.2.0 // indirect github.com/filecoin-project/go-storedcounter v0.1.0 // indirect - github.com/filecoin-project/index-provider v0.9.1 // indirect github.com/filecoin-project/pubsub v1.0.0 // indirect github.com/filecoin-project/specs-actors/v8 v8.0.1 // indirect - github.com/filecoin-project/storetheindex v0.4.30-0.20221114113647-683091f8e893 // indirect github.com/flynn/noise v1.0.0 // indirect github.com/francoispqt/gojay v1.2.13 // indirect github.com/fsnotify/fsnotify v1.5.4 // indirect @@ -182,7 +181,6 @@ require ( github.com/icza/backscanner v0.0.0-20210726202459-ac2ffc679f94 // indirect github.com/ipfs/bbloom v0.0.4 // indirect github.com/ipfs/go-bitfield v1.0.0 // indirect - github.com/ipfs/go-bitswap v0.10.2 // indirect github.com/ipfs/go-blockservice v0.4.0 // indirect github.com/ipfs/go-cidutil v0.1.0 // indirect github.com/ipfs/go-datastore v0.6.0 // indirect @@ -201,8 +199,8 @@ require ( github.com/ipfs/go-ipfs-files v0.1.1 // indirect github.com/ipfs/go-ipfs-http-client v0.4.0 // indirect github.com/ipfs/go-ipfs-posinfo v0.0.1 // indirect - github.com/ipfs/go-ipfs-pq v0.0.2 // indirect - github.com/ipfs/go-ipfs-routing v0.2.1 // indirect + github.com/ipfs/go-ipfs-pq v0.0.3 // indirect + github.com/ipfs/go-ipfs-routing v0.3.0 // indirect github.com/ipfs/go-ipfs-util v0.0.2 // indirect github.com/ipfs/go-ipld-legacy v0.1.1 // indirect github.com/ipfs/go-ipns v0.3.0 // indirect @@ -210,7 +208,7 @@ require ( github.com/ipfs/go-merkledag v0.8.1 // indirect github.com/ipfs/go-metrics-interface v0.0.1 // indirect github.com/ipfs/go-path v0.3.0 // indirect - github.com/ipfs/go-peertaskqueue v0.8.0 // indirect + github.com/ipfs/go-peertaskqueue v0.8.1 // indirect github.com/ipfs/go-unixfs v0.4.0 // indirect github.com/ipfs/go-unixfsnode v1.4.0 // indirect github.com/ipfs/go-verifcid v0.0.2 // indirect @@ -220,6 +218,8 @@ require ( github.com/ipld/go-ipld-adl-hamt v0.0.0-20220616142416-9004dbd839e0 // indirect github.com/ipld/go-ipld-prime v0.20.0 // indirect github.com/ipld/go-ipld-selector-text-lite v0.0.1 // indirect + github.com/ipni/index-provider v0.10.0 // indirect + github.com/ipni/storetheindex v0.5.3-0.20221203123030-16745cb63f15 // indirect github.com/ipsn/go-secp256k1 v0.0.0-20180726113642-9d62b9f0bc52 // indirect github.com/jackpal/go-nat-pmp v1.0.2 // indirect github.com/jbenet/go-random v0.0.0-20190219211222-123a90aedc0c // indirect @@ -306,7 +306,7 @@ require ( github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect github.com/spf13/cast v1.3.1 // indirect - github.com/stretchr/objx v0.4.0 // indirect + github.com/stretchr/objx v0.5.0 // indirect github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc // indirect github.com/twmb/murmur3 v1.1.6 // indirect diff --git a/go.sum b/go.sum index 7631d6042..bdda45e17 100644 --- a/go.sum +++ b/go.sum @@ -320,8 +320,8 @@ github.com/filecoin-project/go-fil-commcid v0.1.0 h1:3R4ds1A9r6cr8mvZBfMYxTS88Oq github.com/filecoin-project/go-fil-commcid v0.1.0/go.mod h1:Eaox7Hvus1JgPrL5+M3+h7aSPHc0cVqpSxA+TxIEpZQ= github.com/filecoin-project/go-fil-commp-hashhash v0.1.0 h1:imrrpZWEHRnNqqv0tN7LXep5bFEVOVmQWHJvl2mgsGo= github.com/filecoin-project/go-fil-commp-hashhash v0.1.0/go.mod h1:73S8WSEWh9vr0fDJVnKADhfIv/d6dCbAGaAGWbdJEI8= -github.com/filecoin-project/go-fil-markets v1.25.2 h1:kVfgaamTC7dkn8KwS5zRJBNEBSNvVqdG3BCoDaUYuCI= -github.com/filecoin-project/go-fil-markets v1.25.2/go.mod h1:dc2oTPU6GH3Qk1nA+Er+hSX64rg+NVykkPIWFBYxcZU= +github.com/filecoin-project/go-fil-markets v1.25.3 h1:50kK+2VBmyh9SuuS/MgcTRaWlVdBdTZLPCzMxw8ONBg= +github.com/filecoin-project/go-fil-markets v1.25.3/go.mod h1:eOIYHfPwyqc64O1HiapvcelfnrTfU7gLQgBf55IYleQ= github.com/filecoin-project/go-hamt-ipld v0.1.5 h1:uoXrKbCQZ49OHpsTCkrThPNelC4W3LPEk0OrS/ytIBM= github.com/filecoin-project/go-hamt-ipld v0.1.5/go.mod h1:6Is+ONR5Cd5R6XZoCse1CWaXZc0Hdb/JeX+EQCQzX24= github.com/filecoin-project/go-hamt-ipld/v2 v2.0.0 h1:b3UDemBYN2HNfk3KOXNuxgTTxlWi3xVvbQP0IT38fvM= @@ -346,8 +346,8 @@ github.com/filecoin-project/go-state-types v0.1.0/go.mod h1:ezYnPf0bNkTsDibL/psS github.com/filecoin-project/go-state-types v0.1.6/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q= github.com/filecoin-project/go-state-types v0.1.8/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q= github.com/filecoin-project/go-state-types v0.1.10/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q= -github.com/filecoin-project/go-state-types v0.10.0-rc2.0.20230213183937-7f1ede218b87 h1:gqKaMwXp8mrvf1Zj+l8mXUPTC2HYf+TG7rcSivO0nDI= -github.com/filecoin-project/go-state-types v0.10.0-rc2.0.20230213183937-7f1ede218b87/go.mod h1:aLIas+W8BWAfpLWEPUOGMPBdhcVwoCG4pIQSQk26024= +github.com/filecoin-project/go-state-types v0.10.0-rc3.0.20230224225638-2fa7a438fd4a h1:ehvxKXl0eeu7rONOPmbVaVrgyDalE4zrwhygcuxJie0= +github.com/filecoin-project/go-state-types v0.10.0-rc3.0.20230224225638-2fa7a438fd4a/go.mod h1:aLIas+W8BWAfpLWEPUOGMPBdhcVwoCG4pIQSQk26024= github.com/filecoin-project/go-statemachine v0.0.0-20200925024713-05bd7c71fbfe/go.mod h1:FGwQgZAt2Gh5mjlwJUlVB62JeYdo+if0xWxSEfBD9ig= github.com/filecoin-project/go-statemachine v1.0.2 h1:421SSWBk8GIoCoWYYTE/d+qCWccgmRH0uXotXRDjUbc= github.com/filecoin-project/go-statemachine v1.0.2/go.mod h1:jZdXXiHa61n4NmgWFG4w8tnqgvZVHYbJ3yW7+y8bF54= @@ -356,10 +356,8 @@ github.com/filecoin-project/go-statestore v0.2.0 h1:cRRO0aPLrxKQCZ2UOQbzFGn4WDNd github.com/filecoin-project/go-statestore v0.2.0/go.mod h1:8sjBYbS35HwPzct7iT4lIXjLlYyPor80aU7t7a/Kspo= github.com/filecoin-project/go-storedcounter v0.1.0 h1:Mui6wSUBC+cQGHbDUBcO7rfh5zQkWJM/CpAZa/uOuus= github.com/filecoin-project/go-storedcounter v0.1.0/go.mod h1:4ceukaXi4vFURIoxYMfKzaRF5Xv/Pinh2oTnoxpv+z8= -github.com/filecoin-project/index-provider v0.9.1 h1:Jnh9dviIHvQxZ2baNoYu3n8z6F9O62ksnVlyREgPyyM= -github.com/filecoin-project/index-provider v0.9.1/go.mod h1:NlHxQcy2iMGfUoUGUzrRxntcpiC50QSnvp68u2VTT40= -github.com/filecoin-project/lotus v1.20.0-hyperspace-nv20 h1:nVEXARksqtebKmD2XVFxVmh3sta+AJp5hF3uk/Ohoug= -github.com/filecoin-project/lotus v1.20.0-hyperspace-nv20/go.mod h1:iwEYFha2TlQEWve62gere63OOm49c/K0zMxt+qNm0+c= +github.com/filecoin-project/lotus v1.20.0-hyperspace-nv21-hotfix-01 h1:iqvKdH6yodx/A0N2O8+Qs8OZ+nOsZBSHlnuRzkAkIPQ= +github.com/filecoin-project/lotus v1.20.0-hyperspace-nv21-hotfix-01/go.mod h1:YXMBUtk9WIuAKhrlF8z/RKVGozcvcyyJRRiHXDRDfMs= github.com/filecoin-project/pubsub v1.0.0 h1:ZTmT27U07e54qV1mMiQo4HDr0buo8I1LDHBYLXlsNXM= github.com/filecoin-project/pubsub v1.0.0/go.mod h1:GkpB33CcUtUNrLPhJgfdy4FDx4OMNR9k+46DHx/Lqrg= github.com/filecoin-project/specs-actors v0.9.13/go.mod h1:TS1AW/7LbG+615j4NsjMK1qlpAwaFsG9w0V2tg2gSao= @@ -380,8 +378,6 @@ github.com/filecoin-project/specs-actors/v7 v7.0.1 h1:w72xCxijK7xs1qzmJiw+WYJaVt github.com/filecoin-project/specs-actors/v7 v7.0.1/go.mod h1:tPLEYXoXhcpyLh69Ccq91SOuLXsPWjHiY27CzawjUEk= github.com/filecoin-project/specs-actors/v8 v8.0.1 h1:4u0tIRJeT5G7F05lwLRIsDnsrN+bJ5Ixj6h49Q7uE2Y= github.com/filecoin-project/specs-actors/v8 v8.0.1/go.mod h1:UYIPg65iPWoFw5NEftREdJwv9b/5yaLKdCgTvNI/2FA= -github.com/filecoin-project/storetheindex v0.4.30-0.20221114113647-683091f8e893 h1:6GCuzxLVHBzlz7y+FkbHh6n0UyoEGWqDwJKQPJoz7bE= -github.com/filecoin-project/storetheindex v0.4.30-0.20221114113647-683091f8e893/go.mod h1:S7590oDimBvXMUtzWsBXoshu9HtYKwtXl47zAK9rcP8= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/flynn/noise v0.0.0-20180327030543-2492fe189ae6/go.mod h1:1i71OnUq3iUe1ma7Lr6yG6/rjvM3emb6yoL7xLFzcVQ= github.com/flynn/noise v1.0.0 h1:DlTHqmzmvcEiKj+4RYo/imoswx/4r6iBlCMfVtrMXpQ= @@ -667,11 +663,11 @@ github.com/ipfs/go-bitswap v0.1.2/go.mod h1:qxSWS4NXGs7jQ6zQvoPY3+NmOfHHG47mhkiL github.com/ipfs/go-bitswap v0.5.1/go.mod h1:P+ckC87ri1xFLvk74NlXdP0Kj9RmWAh4+H78sC6Qopo= github.com/ipfs/go-bitswap v0.6.0/go.mod h1:Hj3ZXdOC5wBJvENtdqsixmzzRukqd8EHLxZLZc3mzRA= github.com/ipfs/go-bitswap v0.10.2 h1:B81RIwkTnIvSYT1ZCzxjYTeF0Ek88xa9r1AMpTfk+9Q= -github.com/ipfs/go-bitswap v0.10.2/go.mod h1:+fZEvycxviZ7c+5KlKwTzLm0M28g2ukCPqiuLfJk4KA= github.com/ipfs/go-block-format v0.0.1/go.mod h1:DK/YYcsSUIVAFNwo/KZCdIIbpN0ROH/baNLgayt4pFc= github.com/ipfs/go-block-format v0.0.2/go.mod h1:AWR46JfpcObNfg3ok2JHDUfdiHRgWhJgCQF+KIgOPJY= -github.com/ipfs/go-block-format v0.0.3 h1:r8t66QstRp/pd/or4dpnbVfXT5Gt7lOqRvC+/dDTpMc= github.com/ipfs/go-block-format v0.0.3/go.mod h1:4LmD4ZUw0mhO+JSKdpWwrzATiEfM7WWgQ8H5l6P8MVk= +github.com/ipfs/go-block-format v0.1.1 h1:129vSO3zwbsYADcyQWcOYiuCpAqt462SFfqFHdFJhhI= +github.com/ipfs/go-block-format v0.1.1/go.mod h1:+McEIT+g52p+zz5xGAABGSOKrzmrdX97bc0USBdWPUs= github.com/ipfs/go-blockservice v0.1.0/go.mod h1:hzmMScl1kXHg3M2BjTymbVPjv627N7sYcvYaKbop39M= github.com/ipfs/go-blockservice v0.2.1/go.mod h1:k6SiwmgyYgs4M/qt+ww6amPeUH9EISLRBnvUurKJhi8= github.com/ipfs/go-blockservice v0.3.0/go.mod h1:P5ppi8IHDC7O+pA0AlGTF09jruB2h+oP3wVVaZl8sfk= @@ -770,11 +766,13 @@ github.com/ipfs/go-ipfs-http-client v0.4.0/go.mod h1:NXzPUKt/QVCuR74a8angJCGOSLP github.com/ipfs/go-ipfs-posinfo v0.0.1 h1:Esoxj+1JgSjX0+ylc0hUmJCOv6V2vFoZiETLR6OtpRs= github.com/ipfs/go-ipfs-posinfo v0.0.1/go.mod h1:SwyeVP+jCwiDu0C313l/8jg6ZxM0qqtlt2a0vILTc1A= github.com/ipfs/go-ipfs-pq v0.0.1/go.mod h1:LWIqQpqfRG3fNc5XsnIhz/wQ2XXGyugQwls7BgUmUfY= -github.com/ipfs/go-ipfs-pq v0.0.2 h1:e1vOOW6MuOwG2lqxcLA+wEn93i/9laCY8sXAw76jFOY= github.com/ipfs/go-ipfs-pq v0.0.2/go.mod h1:LWIqQpqfRG3fNc5XsnIhz/wQ2XXGyugQwls7BgUmUfY= +github.com/ipfs/go-ipfs-pq v0.0.3 h1:YpoHVJB+jzK15mr/xsWC574tyDLkezVrDNeaalQBsTE= +github.com/ipfs/go-ipfs-pq v0.0.3/go.mod h1:btNw5hsHBpRcSSgZtiNm/SLj5gYIZ18AKtv3kERkRb4= github.com/ipfs/go-ipfs-routing v0.1.0/go.mod h1:hYoUkJLyAUKhF58tysKpids8RNDPO42BVMgK5dNsoqY= -github.com/ipfs/go-ipfs-routing v0.2.1 h1:E+whHWhJkdN9YeoHZNj5itzc+OR292AJ2uE9FFiW0BY= github.com/ipfs/go-ipfs-routing v0.2.1/go.mod h1:xiNNiwgjmLqPS1cimvAw6EyB9rkVDbiocA4yY+wRNLM= +github.com/ipfs/go-ipfs-routing v0.3.0 h1:9W/W3N+g+y4ZDeffSgqhgo7BsBSJwPMcyssET9OWevc= +github.com/ipfs/go-ipfs-routing v0.3.0/go.mod h1:dKqtTFIql7e1zYsEuWLyuOU+E0WJWW8JjbTPLParDWo= github.com/ipfs/go-ipfs-util v0.0.1/go.mod h1:spsl5z8KUnrve+73pOhSVZND1SIxPW5RyBCNzQxlJBc= github.com/ipfs/go-ipfs-util v0.0.2 h1:59Sswnk1MFaiq+VcaknX7aYEyGyGDAA73ilhEK2POp8= github.com/ipfs/go-ipfs-util v0.0.2/go.mod h1:CbPtkWJzjLdEcezDns2XYaehFVNXG9zrdrtMecczcsQ= @@ -796,6 +794,8 @@ github.com/ipfs/go-ipld-legacy v0.1.1 h1:BvD8PEuqwBHLTKqlGFTHSwrwFOMkVESEvwIYwR2 github.com/ipfs/go-ipld-legacy v0.1.1/go.mod h1:8AyKFCjgRPsQFf15ZQgDB8Din4DML/fOmKZkkFkrIEg= github.com/ipfs/go-ipns v0.3.0 h1:ai791nTgVo+zTuq2bLvEGmWP1M0A6kGTXUsgv/Yq67A= github.com/ipfs/go-ipns v0.3.0/go.mod h1:3cLT2rbvgPZGkHJoPO1YMJeh6LtkxopCkKFcio/wE24= +github.com/ipfs/go-libipfs v0.4.1 h1:tyu3RRMKFQUyUQt5jyt5SmDnls93H4Tr3HifL50zihg= +github.com/ipfs/go-libipfs v0.4.1/go.mod h1:Ad8ybPqwCkl2cNiNUMvM/iaVc/5bwNpHu8RPZ5te1hw= github.com/ipfs/go-log v0.0.1/go.mod h1:kL1d2/hzSpI0thNYjiKfjanbVNU+IIGA/WnNESY9leM= github.com/ipfs/go-log v1.0.0/go.mod h1:JO7RzlMK6rA+CIxFMLOuB6Wf5b81GDiKElL7UPSIKjA= github.com/ipfs/go-log v1.0.1/go.mod h1:HuWlQttfN6FWNHRhlY5yMk/lW7evQC0HHGOxEwMRR8I= @@ -833,8 +833,8 @@ github.com/ipfs/go-path v0.3.0/go.mod h1:NOScsVgxfC/eIw4nz6OiGwK42PjaSJ4Y/ZFPn1X github.com/ipfs/go-peertaskqueue v0.1.0/go.mod h1:Jmk3IyCcfl1W3jTW3YpghSwSEC6IJ3Vzz/jUmWw8Z0U= github.com/ipfs/go-peertaskqueue v0.7.0/go.mod h1:M/akTIE/z1jGNXMU7kFB4TeSEFvj68ow0Rrb04donIU= github.com/ipfs/go-peertaskqueue v0.7.1/go.mod h1:M/akTIE/z1jGNXMU7kFB4TeSEFvj68ow0Rrb04donIU= -github.com/ipfs/go-peertaskqueue v0.8.0 h1:JyNO144tfu9bx6Hpo119zvbEL9iQ760FHOiJYsUjqaU= -github.com/ipfs/go-peertaskqueue v0.8.0/go.mod h1:cz8hEnnARq4Du5TGqiWKgMr/BOSQ5XOgMOh1K5YYKKM= +github.com/ipfs/go-peertaskqueue v0.8.1 h1:YhxAs1+wxb5jk7RvS0LHdyiILpNmRIRnZVztekOF0pg= +github.com/ipfs/go-peertaskqueue v0.8.1/go.mod h1:Oxxd3eaK279FxeydSPPVGHzbwVeHjatZ2GA8XD+KbPU= github.com/ipfs/go-unixfs v0.2.2-0.20190827150610-868af2e9e5cb/go.mod h1:IwAAgul1UQIcNZzKPYZWOCijryFBeCV79cNubPzol+k= github.com/ipfs/go-unixfs v0.2.4/go.mod h1:SUdisfUjNoSDzzhGVxvCL9QO/nKdwXdr+gbMUdqcbYw= github.com/ipfs/go-unixfs v0.3.1/go.mod h1:h4qfQYzghiIc8ZNFKiLMFWOTzrWIAtzYQ59W/pCFf1o= @@ -878,6 +878,10 @@ github.com/ipld/go-ipld-prime/storage/bsadapter v0.0.0-20211210234204-ce2a1c70cd github.com/ipld/go-ipld-prime/storage/bsadapter v0.0.0-20211210234204-ce2a1c70cd73/go.mod h1:2PJ0JgxyB08t0b2WKrcuqI3di0V+5n6RS/LTUJhkoxY= github.com/ipld/go-ipld-selector-text-lite v0.0.1 h1:lNqFsQpBHc3p5xHob2KvEg/iM5dIFn6iw4L/Hh+kS1Y= github.com/ipld/go-ipld-selector-text-lite v0.0.1/go.mod h1:U2CQmFb+uWzfIEF3I1arrDa5rwtj00PrpiwwCO+k1RM= +github.com/ipni/index-provider v0.10.0 h1:nu8YBxzRopdjwZHsgCUuC4AHpq88VVHJYrbkqUDx7eg= +github.com/ipni/index-provider v0.10.0/go.mod h1:InSXbZp2p/ZhAwiDElG/wzjnA1ea1iJ3hhyiAHrD+Vo= +github.com/ipni/storetheindex v0.5.3-0.20221203123030-16745cb63f15 h1:qJq6QtLk+9nQi3CDBhNfJ1cjZ4pghjCHcQUZ1mWbF0k= +github.com/ipni/storetheindex v0.5.3-0.20221203123030-16745cb63f15/go.mod h1:c/NS640Iu2NrCCIErnUhsUM5KVEyeXymgtNnx6eDwMU= github.com/ipsn/go-secp256k1 v0.0.0-20180726113642-9d62b9f0bc52 h1:QG4CGBqCeuBo6aZlGAamSkxWdgWfZGeE49eUOWJPA4c= github.com/ipsn/go-secp256k1 v0.0.0-20180726113642-9d62b9f0bc52/go.mod h1:fdg+/X9Gg4AsAIzWpEHwnqd+QY3b7lajxyjE1m4hkq4= github.com/jackpal/gateway v1.0.5/go.mod h1:lTpwd4ACLXmpyiCTRtfiNyVnUmqT9RivzCDQetPfnjA= @@ -1005,8 +1009,8 @@ github.com/libp2p/go-libp2p v0.14.3/go.mod h1:d12V4PdKbpL0T1/gsUNN8DfgMuRPDX8bS2 github.com/libp2p/go-libp2p v0.14.4/go.mod h1:EIRU0Of4J5S8rkockZM7eJp2S0UrCyi55m2kJVru3rM= github.com/libp2p/go-libp2p v0.17.0/go.mod h1:Fkin50rsGdv5mm5BshBUtPRZknt9esfmYXBOYcwOTgw= github.com/libp2p/go-libp2p v0.19.4/go.mod h1:MIt8y481VDhUe4ErWi1a4bvt/CjjFfOq6kZTothWIXY= -github.com/libp2p/go-libp2p v0.23.2 h1:yqyTeKQJyofWXxEv/eEVUvOrGdt/9x+0PIQ4N1kaxmE= -github.com/libp2p/go-libp2p v0.23.2/go.mod h1:s9DEa5NLR4g+LZS+md5uGU4emjMWFiqkZr6hBTY8UxI= +github.com/libp2p/go-libp2p v0.23.4 h1:hWi9XHSOVFR1oDWRk7rigfyA4XNMuYL20INNybP9LP8= +github.com/libp2p/go-libp2p v0.23.4/go.mod h1:s9DEa5NLR4g+LZS+md5uGU4emjMWFiqkZr6hBTY8UxI= github.com/libp2p/go-libp2p-asn-util v0.1.0/go.mod h1:wu+AnM9Ii2KgO5jMmS1rz9dvzTdj8BXqsPR9HR0XB7I= github.com/libp2p/go-libp2p-asn-util v0.2.0 h1:rg3+Os8jbnO5DxkC7K/Utdi+DkY3q/d1/1q+8WeNAsw= github.com/libp2p/go-libp2p-asn-util v0.2.0/go.mod h1:WoaWxbHKBymSN41hWSq/lGKJEca7TNm58+gGJi2WsLI= @@ -1415,8 +1419,8 @@ github.com/multiformats/go-multiaddr v0.3.3/go.mod h1:lCKNGP1EQ1eZ35Za2wlqnabm9x github.com/multiformats/go-multiaddr v0.4.0/go.mod h1:YcpyLH8ZPudLxQlemYBPhSm0/oCXAT8Z4mzFpyoPyRc= github.com/multiformats/go-multiaddr v0.4.1/go.mod h1:3afI9HfVW8csiF8UZqtpYRiDyew8pRX7qLIGHu9FLuM= github.com/multiformats/go-multiaddr v0.5.0/go.mod h1:3KAxNkUqLTJ20AAwN4XVX4kZar+bR+gh4zgbfr3SNug= -github.com/multiformats/go-multiaddr v0.7.0 h1:gskHcdaCyPtp9XskVwtvEeQOG465sCohbQIirSyqxrc= -github.com/multiformats/go-multiaddr v0.7.0/go.mod h1:Fs50eBDWvZu+l3/9S6xAE7ZYj6yhxlvaVZjakWN7xRs= +github.com/multiformats/go-multiaddr v0.8.0 h1:aqjksEcqK+iD/Foe1RRFsGZh8+XFiGo7FgUCZlpv3LU= +github.com/multiformats/go-multiaddr v0.8.0/go.mod h1:Fs50eBDWvZu+l3/9S6xAE7ZYj6yhxlvaVZjakWN7xRs= github.com/multiformats/go-multiaddr-dns v0.0.1/go.mod h1:9kWcqw/Pj6FwxAwW38n/9403szc57zJPs45fmnznu3Q= github.com/multiformats/go-multiaddr-dns v0.0.2/go.mod h1:9kWcqw/Pj6FwxAwW38n/9403szc57zJPs45fmnznu3Q= github.com/multiformats/go-multiaddr-dns v0.2.0/go.mod h1:TJ5pr5bBO7Y1B18djPuRsVkduhQH2YqYSbxWJzYGdK0= @@ -1719,8 +1723,9 @@ github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3 github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0 h1:M2gUjqZET1qApGOWNSnZ49BAIMX4F/1plDv3+l31EJ4= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -1728,8 +1733,9 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= diff --git a/lens/util/store.go b/lens/util/store.go index ec1ea18c5..9426114e2 100644 --- a/lens/util/store.go +++ b/lens/util/store.go @@ -10,9 +10,9 @@ import ( "github.com/filecoin-project/lotus/blockstore" "github.com/filecoin-project/specs-actors/actors/util/adt" lru "github.com/hashicorp/golang-lru" - blocks "github.com/ipfs/go-block-format" - "github.com/ipfs/go-cid" + cid "github.com/ipfs/go-cid" cbor "github.com/ipfs/go-ipld-cbor" + blocks "github.com/ipfs/go-libipfs/blocks" cbg "github.com/whyrusleeping/cbor-gen" ) diff --git a/tasks/actorstate/miner/extraction/mocks/state.go b/tasks/actorstate/miner/extraction/mocks/state.go index 450fef4be..bd1e311e4 100644 --- a/tasks/actorstate/miner/extraction/mocks/state.go +++ b/tasks/actorstate/miner/extraction/mocks/state.go @@ -1,7 +1,7 @@ package mocks import ( - "github.com/filecoin-project/go-address" + address "github.com/filecoin-project/go-address" "github.com/filecoin-project/lotus/chain/types" "github.com/stretchr/testify/mock"