This commit is contained in:
vyzo 2022-04-04 14:25:03 +03:00
parent 770608aef1
commit cdd5420e0c
116 changed files with 2389 additions and 1337 deletions

View File

@ -27,6 +27,7 @@ import (
builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin"
)
func init() {
@ -35,38 +36,122 @@ func init() {
return load0(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version0, "account"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load0(store, root)
})
}
builtin.RegisterActorState(builtin2.AccountActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load2(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version2, "account"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load2(store, root)
})
}
builtin.RegisterActorState(builtin3.AccountActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load3(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version3, "account"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load3(store, root)
})
}
builtin.RegisterActorState(builtin4.AccountActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load4(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version4, "account"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load4(store, root)
})
}
builtin.RegisterActorState(builtin5.AccountActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load5(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version5, "account"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load5(store, root)
})
}
builtin.RegisterActorState(builtin6.AccountActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load6(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version6, "account"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load6(store, root)
})
}
builtin.RegisterActorState(builtin7.AccountActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load7(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version7, "account"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load7(store, root)
})
}
builtin.RegisterActorState(builtin8.AccountActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load8(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version8, "account"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load8(store, root)
})
}
}
var Methods = builtin4.MethodsAccount
func Load(store adt.Store, act *types.Actor) (State, error) {
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
if name != "account" {
return nil, xerrors.Errorf("actor code is not account: %s", name)
}
switch av {
case actors.Version0:
return load0(store, act.Head)
case actors.Version2:
return load2(store, act.Head)
case actors.Version3:
return load3(store, act.Head)
case actors.Version4:
return load4(store, act.Head)
case actors.Version5:
return load5(store, act.Head)
case actors.Version6:
return load6(store, act.Head)
case actors.Version7:
return load7(store, act.Head)
case actors.Version8:
return load8(store, act.Head)
default:
return nil, xerrors.Errorf("unknown actor version: %d", av)
}
}
switch act.Code {
case builtin0.AccountActorCodeID:
@ -124,11 +209,15 @@ func MakeState(store adt.Store, av actors.Version, addr address.Address) (State,
case actors.Version8:
return make8(store, addr)
}
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
if c, ok := actors.GetActorCodeID(av, "account"); ok {
return c, nil
}
switch av {
case actors.Version0:

View File

@ -22,7 +22,7 @@ func load0(store adt.Store, root cid.Cid) (State, error) {
func make0(store adt.Store, addr address.Address) (State, error) {
out := state0{store: store}
out.State = account0.State{Address: addr}
out.State = account0.State{Address:addr}
return &out, nil
}
@ -37,4 +37,4 @@ func (s *state0) PubkeyAddress() (address.Address, error) {
func (s *state0) GetState() interface{} {
return &s.State
}
}

View File

@ -22,7 +22,7 @@ func load2(store adt.Store, root cid.Cid) (State, error) {
func make2(store adt.Store, addr address.Address) (State, error) {
out := state2{store: store}
out.State = account2.State{Address: addr}
out.State = account2.State{Address:addr}
return &out, nil
}
@ -37,4 +37,4 @@ func (s *state2) PubkeyAddress() (address.Address, error) {
func (s *state2) GetState() interface{} {
return &s.State
}
}

View File

@ -22,7 +22,7 @@ func load3(store adt.Store, root cid.Cid) (State, error) {
func make3(store adt.Store, addr address.Address) (State, error) {
out := state3{store: store}
out.State = account3.State{Address: addr}
out.State = account3.State{Address:addr}
return &out, nil
}
@ -37,4 +37,4 @@ func (s *state3) PubkeyAddress() (address.Address, error) {
func (s *state3) GetState() interface{} {
return &s.State
}
}

View File

@ -22,7 +22,7 @@ func load4(store adt.Store, root cid.Cid) (State, error) {
func make4(store adt.Store, addr address.Address) (State, error) {
out := state4{store: store}
out.State = account4.State{Address: addr}
out.State = account4.State{Address:addr}
return &out, nil
}
@ -37,4 +37,4 @@ func (s *state4) PubkeyAddress() (address.Address, error) {
func (s *state4) GetState() interface{} {
return &s.State
}
}

View File

@ -22,7 +22,7 @@ func load5(store adt.Store, root cid.Cid) (State, error) {
func make5(store adt.Store, addr address.Address) (State, error) {
out := state5{store: store}
out.State = account5.State{Address: addr}
out.State = account5.State{Address:addr}
return &out, nil
}
@ -37,4 +37,4 @@ func (s *state5) PubkeyAddress() (address.Address, error) {
func (s *state5) GetState() interface{} {
return &s.State
}
}

View File

@ -22,7 +22,7 @@ func load6(store adt.Store, root cid.Cid) (State, error) {
func make6(store adt.Store, addr address.Address) (State, error) {
out := state6{store: store}
out.State = account6.State{Address: addr}
out.State = account6.State{Address:addr}
return &out, nil
}
@ -37,4 +37,4 @@ func (s *state6) PubkeyAddress() (address.Address, error) {
func (s *state6) GetState() interface{} {
return &s.State
}
}

View File

@ -22,7 +22,7 @@ func load7(store adt.Store, root cid.Cid) (State, error) {
func make7(store adt.Store, addr address.Address) (State, error) {
out := state7{store: store}
out.State = account7.State{Address: addr}
out.State = account7.State{Address:addr}
return &out, nil
}
@ -37,4 +37,4 @@ func (s *state7) PubkeyAddress() (address.Address, error) {
func (s *state7) GetState() interface{} {
return &s.State
}
}

View File

@ -22,7 +22,7 @@ func load8(store adt.Store, root cid.Cid) (State, error) {
func make8(store adt.Store, addr address.Address) (State, error) {
out := state8{store: store}
out.State = account8.State{Address: addr}
out.State = account8.State{Address:addr}
return &out, nil
}
@ -37,4 +37,4 @@ func (s *state8) PubkeyAddress() (address.Address, error) {
func (s *state8) GetState() interface{} {
return &s.State
}
}

View File

@ -5,33 +5,36 @@ import (
"github.com/ipfs/go-cid"
"golang.org/x/xerrors"
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
smoothing0 "github.com/filecoin-project/specs-actors/actors/util/smoothing"
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
smoothing2 "github.com/filecoin-project/specs-actors/v2/actors/util/smoothing"
builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin"
smoothing3 "github.com/filecoin-project/specs-actors/v3/actors/util/smoothing"
builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin"
smoothing4 "github.com/filecoin-project/specs-actors/v4/actors/util/smoothing"
builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin"
smoothing5 "github.com/filecoin-project/specs-actors/v5/actors/util/smoothing"
builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin"
smoothing6 "github.com/filecoin-project/specs-actors/v6/actors/util/smoothing"
builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
smoothing7 "github.com/filecoin-project/specs-actors/v7/actors/util/smoothing"
builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin"
smoothing8 "github.com/filecoin-project/specs-actors/v8/actors/util/smoothing"
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
smoothing0 "github.com/filecoin-project/specs-actors/actors/util/smoothing"
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
smoothing2 "github.com/filecoin-project/specs-actors/v2/actors/util/smoothing"
builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin"
smoothing3 "github.com/filecoin-project/specs-actors/v3/actors/util/smoothing"
builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin"
smoothing4 "github.com/filecoin-project/specs-actors/v4/actors/util/smoothing"
builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin"
smoothing5 "github.com/filecoin-project/specs-actors/v5/actors/util/smoothing"
builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin"
smoothing6 "github.com/filecoin-project/specs-actors/v6/actors/util/smoothing"
builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
smoothing7 "github.com/filecoin-project/specs-actors/v7/actors/util/smoothing"
builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin"
smoothing8 "github.com/filecoin-project/specs-actors/v8/actors/util/smoothing"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/cbor"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/types"
@ -72,53 +75,55 @@ func QAPowerForWeight(size abi.SectorSize, duration abi.ChainEpoch, dealWeight,
return miner8.QAPowerForWeight(size, duration, dealWeight, verifiedWeight)
}
func FromV0FilterEstimate(v0 smoothing0.FilterEstimate) FilterEstimate {
return (FilterEstimate)(v0) //nolint:unconvert
func FromV0FilterEstimate(v0 smoothing0.FilterEstimate) FilterEstimate {
return (FilterEstimate)(v0) //nolint:unconvert
}
}
func FromV2FilterEstimate(v2 smoothing2.FilterEstimate) FilterEstimate {
return (FilterEstimate)(v2)
}
func FromV2FilterEstimate(v2 smoothing2.FilterEstimate) FilterEstimate {
func FromV3FilterEstimate(v3 smoothing3.FilterEstimate) FilterEstimate {
return (FilterEstimate)(v3)
}
return (FilterEstimate)(v2)
func FromV4FilterEstimate(v4 smoothing4.FilterEstimate) FilterEstimate {
return (FilterEstimate)(v4)
}
}
func FromV5FilterEstimate(v5 smoothing5.FilterEstimate) FilterEstimate {
return (FilterEstimate)(v5)
}
func FromV3FilterEstimate(v3 smoothing3.FilterEstimate) FilterEstimate {
func FromV6FilterEstimate(v6 smoothing6.FilterEstimate) FilterEstimate {
return (FilterEstimate)(v6)
}
return (FilterEstimate)(v3)
func FromV7FilterEstimate(v7 smoothing7.FilterEstimate) FilterEstimate {
return (FilterEstimate)(v7)
}
}
func FromV8FilterEstimate(v8 smoothing8.FilterEstimate) FilterEstimate {
return (FilterEstimate)(v8)
}
func FromV4FilterEstimate(v4 smoothing4.FilterEstimate) FilterEstimate {
return (FilterEstimate)(v4)
}
func FromV5FilterEstimate(v5 smoothing5.FilterEstimate) FilterEstimate {
return (FilterEstimate)(v5)
}
func FromV6FilterEstimate(v6 smoothing6.FilterEstimate) FilterEstimate {
return (FilterEstimate)(v6)
}
func FromV7FilterEstimate(v7 smoothing7.FilterEstimate) FilterEstimate {
return (FilterEstimate)(v7)
}
func FromV8FilterEstimate(v8 smoothing8.FilterEstimate) FilterEstimate {
return (FilterEstimate)(v8)
}
type ActorStateLoader func(store adt.Store, root cid.Cid) (cbor.Marshaler, error)
@ -137,219 +142,249 @@ func Load(store adt.Store, act *types.Actor) (cbor.Marshaler, error) {
}
func ActorNameByCode(c cid.Cid) string {
name, _, ok := actors.GetActorMetaByCode(c)
if ok {
return name
}
switch {
case builtin0.IsBuiltinActor(c):
return builtin0.ActorNameByCode(c)
case builtin2.IsBuiltinActor(c):
return builtin2.ActorNameByCode(c)
case builtin3.IsBuiltinActor(c):
return builtin3.ActorNameByCode(c)
case builtin4.IsBuiltinActor(c):
return builtin4.ActorNameByCode(c)
case builtin5.IsBuiltinActor(c):
return builtin5.ActorNameByCode(c)
case builtin6.IsBuiltinActor(c):
return builtin6.ActorNameByCode(c)
case builtin7.IsBuiltinActor(c):
return builtin7.ActorNameByCode(c)
case builtin8.IsBuiltinActor(c):
return builtin8.ActorNameByCode(c)
case builtin0.IsBuiltinActor(c):
return builtin0.ActorNameByCode(c)
case builtin2.IsBuiltinActor(c):
return builtin2.ActorNameByCode(c)
case builtin3.IsBuiltinActor(c):
return builtin3.ActorNameByCode(c)
case builtin4.IsBuiltinActor(c):
return builtin4.ActorNameByCode(c)
case builtin5.IsBuiltinActor(c):
return builtin5.ActorNameByCode(c)
case builtin6.IsBuiltinActor(c):
return builtin6.ActorNameByCode(c)
case builtin7.IsBuiltinActor(c):
return builtin7.ActorNameByCode(c)
case builtin8.IsBuiltinActor(c):
return builtin8.ActorNameByCode(c)
default:
return "<unknown>"
}
}
func IsBuiltinActor(c cid.Cid) bool {
if builtin0.IsBuiltinActor(c) {
return true
}
if builtin2.IsBuiltinActor(c) {
return true
}
if builtin3.IsBuiltinActor(c) {
return true
}
if builtin4.IsBuiltinActor(c) {
return true
}
if builtin5.IsBuiltinActor(c) {
return true
}
if builtin6.IsBuiltinActor(c) {
return true
}
if builtin7.IsBuiltinActor(c) {
return true
}
if builtin8.IsBuiltinActor(c) {
return true
_, _, ok := actors.GetActorMetaByCode(c)
if ok {
return true
}
if builtin0.IsBuiltinActor(c) {
return true
}
if builtin2.IsBuiltinActor(c) {
return true
}
if builtin3.IsBuiltinActor(c) {
return true
}
if builtin4.IsBuiltinActor(c) {
return true
}
if builtin5.IsBuiltinActor(c) {
return true
}
if builtin6.IsBuiltinActor(c) {
return true
}
if builtin7.IsBuiltinActor(c) {
return true
}
if builtin8.IsBuiltinActor(c) {
return true
}
return false
}
func IsAccountActor(c cid.Cid) bool {
if c == builtin0.AccountActorCodeID {
return true
}
if c == builtin2.AccountActorCodeID {
return true
}
if c == builtin3.AccountActorCodeID {
return true
}
if c == builtin4.AccountActorCodeID {
return true
}
if c == builtin5.AccountActorCodeID {
return true
}
if c == builtin6.AccountActorCodeID {
return true
}
if c == builtin7.AccountActorCodeID {
return true
}
if c == builtin8.AccountActorCodeID {
return true
name, _, ok := actors.GetActorMetaByCode(c)
if ok {
return name == "account"
}
if c == builtin0.AccountActorCodeID {
return true
}
if c == builtin2.AccountActorCodeID {
return true
}
if c == builtin3.AccountActorCodeID {
return true
}
if c == builtin4.AccountActorCodeID {
return true
}
if c == builtin5.AccountActorCodeID {
return true
}
if c == builtin6.AccountActorCodeID {
return true
}
if c == builtin7.AccountActorCodeID {
return true
}
if c == builtin8.AccountActorCodeID {
return true
}
return false
}
func IsStorageMinerActor(c cid.Cid) bool {
if c == builtin0.StorageMinerActorCodeID {
return true
}
if c == builtin2.StorageMinerActorCodeID {
return true
}
if c == builtin3.StorageMinerActorCodeID {
return true
}
if c == builtin4.StorageMinerActorCodeID {
return true
}
if c == builtin5.StorageMinerActorCodeID {
return true
}
if c == builtin6.StorageMinerActorCodeID {
return true
}
if c == builtin7.StorageMinerActorCodeID {
return true
}
if c == builtin8.StorageMinerActorCodeID {
return true
name, _, ok := actors.GetActorMetaByCode(c)
if ok {
return name == "storageminer"
}
if c == builtin0.StorageMinerActorCodeID {
return true
}
if c == builtin2.StorageMinerActorCodeID {
return true
}
if c == builtin3.StorageMinerActorCodeID {
return true
}
if c == builtin4.StorageMinerActorCodeID {
return true
}
if c == builtin5.StorageMinerActorCodeID {
return true
}
if c == builtin6.StorageMinerActorCodeID {
return true
}
if c == builtin7.StorageMinerActorCodeID {
return true
}
if c == builtin8.StorageMinerActorCodeID {
return true
}
return false
}
func IsMultisigActor(c cid.Cid) bool {
if c == builtin0.MultisigActorCodeID {
return true
}
if c == builtin2.MultisigActorCodeID {
return true
}
if c == builtin3.MultisigActorCodeID {
return true
}
if c == builtin4.MultisigActorCodeID {
return true
}
if c == builtin5.MultisigActorCodeID {
return true
}
if c == builtin6.MultisigActorCodeID {
return true
}
if c == builtin7.MultisigActorCodeID {
return true
}
if c == builtin8.MultisigActorCodeID {
return true
name, _, ok := actors.GetActorMetaByCode(c)
if ok {
return name == "multisig"
}
if c == builtin0.MultisigActorCodeID {
return true
}
if c == builtin2.MultisigActorCodeID {
return true
}
if c == builtin3.MultisigActorCodeID {
return true
}
if c == builtin4.MultisigActorCodeID {
return true
}
if c == builtin5.MultisigActorCodeID {
return true
}
if c == builtin6.MultisigActorCodeID {
return true
}
if c == builtin7.MultisigActorCodeID {
return true
}
if c == builtin8.MultisigActorCodeID {
return true
}
return false
}
func IsPaymentChannelActor(c cid.Cid) bool {
if c == builtin0.PaymentChannelActorCodeID {
return true
}
if c == builtin2.PaymentChannelActorCodeID {
return true
}
if c == builtin3.PaymentChannelActorCodeID {
return true
}
if c == builtin4.PaymentChannelActorCodeID {
return true
}
if c == builtin5.PaymentChannelActorCodeID {
return true
}
if c == builtin6.PaymentChannelActorCodeID {
return true
}
if c == builtin7.PaymentChannelActorCodeID {
return true
}
if c == builtin8.PaymentChannelActorCodeID {
return true
name, _, ok := actors.GetActorMetaByCode(c)
if ok {
return name == "paymentchannel"
}
if c == builtin0.PaymentChannelActorCodeID {
return true
}
if c == builtin2.PaymentChannelActorCodeID {
return true
}
if c == builtin3.PaymentChannelActorCodeID {
return true
}
if c == builtin4.PaymentChannelActorCodeID {
return true
}
if c == builtin5.PaymentChannelActorCodeID {
return true
}
if c == builtin6.PaymentChannelActorCodeID {
return true
}
if c == builtin7.PaymentChannelActorCodeID {
return true
}
if c == builtin8.PaymentChannelActorCodeID {
return true
}
return false
}

View File

@ -3,8 +3,8 @@ package cron
import (
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/ipfs/go-cid"
"golang.org/x/xerrors"
"github.com/ipfs/go-cid"
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
@ -21,6 +21,7 @@ import (
builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin"
)
func MakeState(store adt.Store, av actors.Version) (State, error) {
@ -50,11 +51,15 @@ func MakeState(store adt.Store, av actors.Version) (State, error) {
case actors.Version8:
return make8(store)
}
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
if c, ok := actors.GetActorCodeID(av, "cron"); ok {
return c, nil
}
switch av {
case actors.Version0:
@ -91,6 +96,7 @@ var (
Methods = builtin8.MethodsCron
)
type State interface {
GetState() interface{}
}

View File

@ -32,4 +32,4 @@ type state0 struct {
func (s *state0) GetState() interface{} {
return &s.State
}
}

View File

@ -32,4 +32,4 @@ type state2 struct {
func (s *state2) GetState() interface{} {
return &s.State
}
}

View File

@ -32,4 +32,4 @@ type state3 struct {
func (s *state3) GetState() interface{} {
return &s.State
}
}

View File

@ -32,4 +32,4 @@ type state4 struct {
func (s *state4) GetState() interface{} {
return &s.State
}
}

View File

@ -32,4 +32,4 @@ type state5 struct {
func (s *state5) GetState() interface{} {
return &s.State
}
}

View File

@ -32,4 +32,4 @@ type state6 struct {
func (s *state6) GetState() interface{} {
return &s.State
}
}

View File

@ -32,4 +32,4 @@ type state7 struct {
func (s *state7) GetState() interface{} {
return &s.State
}
}

View File

@ -32,4 +32,4 @@ type state8 struct {
func (s *state8) GetState() interface{} {
return &s.State
}
}

View File

@ -29,6 +29,7 @@ import (
builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin"
)
func init() {
@ -37,33 +38,81 @@ func init() {
return load0(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version0, "init"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load0(store, root)
})
}
builtin.RegisterActorState(builtin2.InitActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load2(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version2, "init"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load2(store, root)
})
}
builtin.RegisterActorState(builtin3.InitActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load3(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version3, "init"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load3(store, root)
})
}
builtin.RegisterActorState(builtin4.InitActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load4(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version4, "init"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load4(store, root)
})
}
builtin.RegisterActorState(builtin5.InitActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load5(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version5, "init"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load5(store, root)
})
}
builtin.RegisterActorState(builtin6.InitActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load6(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version6, "init"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load6(store, root)
})
}
builtin.RegisterActorState(builtin7.InitActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load7(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version7, "init"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load7(store, root)
})
}
builtin.RegisterActorState(builtin8.InitActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load8(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version8, "init"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load8(store, root)
})
}
}
var (
@ -72,6 +121,42 @@ var (
)
func Load(store adt.Store, act *types.Actor) (State, error) {
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
if name != "init" {
return nil, xerrors.Errorf("actor code is not init: %s", name)
}
switch av {
case actors.Version0:
return load0(store, act.Head)
case actors.Version2:
return load2(store, act.Head)
case actors.Version3:
return load3(store, act.Head)
case actors.Version4:
return load4(store, act.Head)
case actors.Version5:
return load5(store, act.Head)
case actors.Version6:
return load6(store, act.Head)
case actors.Version7:
return load7(store, act.Head)
case actors.Version8:
return load8(store, act.Head)
default:
return nil, xerrors.Errorf("unknown actor version: %d", av)
}
}
switch act.Code {
case builtin0.InitActorCodeID:
@ -129,11 +214,15 @@ func MakeState(store adt.Store, av actors.Version, networkName string) (State, e
case actors.Version8:
return make8(store, networkName)
}
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
if c, ok := actors.GetActorCodeID(av, "init"); ok {
return c, nil
}
switch av {
case actors.Version0:

View File

@ -10,6 +10,8 @@ import (
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/node/modules/dtypes"
init0 "github.com/filecoin-project/specs-actors/actors/builtin/init"
adt0 "github.com/filecoin-project/specs-actors/actors/util/adt"
)
@ -27,14 +29,14 @@ func load0(store adt.Store, root cid.Cid) (State, error) {
func make0(store adt.Store, networkName string) (State, error) {
out := state0{store: store}
mr, err := adt0.MakeEmptyMap(store).Root()
if err != nil {
return nil, err
}
mr, err := adt0.MakeEmptyMap(store).Root()
if err != nil {
return nil, err
}
out.State = *init0.ConstructState(mr, networkName)
out.State = *init0.ConstructState(mr, networkName)
return &out, nil
}
@ -109,4 +111,4 @@ func (s *state0) AddressMap() (adt.Map, error) {
func (s *state0) GetState() interface{} {
return &s.State
}
}

View File

@ -10,6 +10,8 @@ import (
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/node/modules/dtypes"
init2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/init"
adt2 "github.com/filecoin-project/specs-actors/v2/actors/util/adt"
)
@ -27,14 +29,14 @@ func load2(store adt.Store, root cid.Cid) (State, error) {
func make2(store adt.Store, networkName string) (State, error) {
out := state2{store: store}
mr, err := adt2.MakeEmptyMap(store).Root()
if err != nil {
return nil, err
}
mr, err := adt2.MakeEmptyMap(store).Root()
if err != nil {
return nil, err
}
out.State = *init2.ConstructState(mr, networkName)
out.State = *init2.ConstructState(mr, networkName)
return &out, nil
}
@ -109,4 +111,4 @@ func (s *state2) AddressMap() (adt.Map, error) {
func (s *state2) GetState() interface{} {
return &s.State
}
}

View File

@ -10,8 +10,10 @@ import (
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/node/modules/dtypes"
builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin"
init3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/init"
adt3 "github.com/filecoin-project/specs-actors/v3/actors/util/adt"
)
@ -29,14 +31,14 @@ func load3(store adt.Store, root cid.Cid) (State, error) {
func make3(store adt.Store, networkName string) (State, error) {
out := state3{store: store}
s, err := init3.ConstructState(store, networkName)
if err != nil {
return nil, err
}
s, err := init3.ConstructState(store, networkName)
if err != nil {
return nil, err
}
out.State = *s
out.State = *s
return &out, nil
}
@ -111,4 +113,4 @@ func (s *state3) AddressMap() (adt.Map, error) {
func (s *state3) GetState() interface{} {
return &s.State
}
}

View File

@ -10,8 +10,10 @@ import (
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/node/modules/dtypes"
builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin"
init4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/init"
adt4 "github.com/filecoin-project/specs-actors/v4/actors/util/adt"
)
@ -29,14 +31,14 @@ func load4(store adt.Store, root cid.Cid) (State, error) {
func make4(store adt.Store, networkName string) (State, error) {
out := state4{store: store}
s, err := init4.ConstructState(store, networkName)
if err != nil {
return nil, err
}
s, err := init4.ConstructState(store, networkName)
if err != nil {
return nil, err
}
out.State = *s
out.State = *s
return &out, nil
}
@ -111,4 +113,4 @@ func (s *state4) AddressMap() (adt.Map, error) {
func (s *state4) GetState() interface{} {
return &s.State
}
}

View File

@ -10,8 +10,10 @@ import (
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/node/modules/dtypes"
builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin"
init5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/init"
adt5 "github.com/filecoin-project/specs-actors/v5/actors/util/adt"
)
@ -29,14 +31,14 @@ func load5(store adt.Store, root cid.Cid) (State, error) {
func make5(store adt.Store, networkName string) (State, error) {
out := state5{store: store}
s, err := init5.ConstructState(store, networkName)
if err != nil {
return nil, err
}
s, err := init5.ConstructState(store, networkName)
if err != nil {
return nil, err
}
out.State = *s
out.State = *s
return &out, nil
}
@ -111,4 +113,4 @@ func (s *state5) AddressMap() (adt.Map, error) {
func (s *state5) GetState() interface{} {
return &s.State
}
}

View File

@ -10,8 +10,10 @@ import (
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/node/modules/dtypes"
builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin"
init6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/init"
adt6 "github.com/filecoin-project/specs-actors/v6/actors/util/adt"
)
@ -29,14 +31,14 @@ func load6(store adt.Store, root cid.Cid) (State, error) {
func make6(store adt.Store, networkName string) (State, error) {
out := state6{store: store}
s, err := init6.ConstructState(store, networkName)
if err != nil {
return nil, err
}
s, err := init6.ConstructState(store, networkName)
if err != nil {
return nil, err
}
out.State = *s
out.State = *s
return &out, nil
}
@ -111,4 +113,4 @@ func (s *state6) AddressMap() (adt.Map, error) {
func (s *state6) GetState() interface{} {
return &s.State
}
}

View File

@ -10,8 +10,10 @@ import (
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/node/modules/dtypes"
builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
init7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/init"
adt7 "github.com/filecoin-project/specs-actors/v7/actors/util/adt"
)
@ -29,14 +31,14 @@ func load7(store adt.Store, root cid.Cid) (State, error) {
func make7(store adt.Store, networkName string) (State, error) {
out := state7{store: store}
s, err := init7.ConstructState(store, networkName)
if err != nil {
return nil, err
}
s, err := init7.ConstructState(store, networkName)
if err != nil {
return nil, err
}
out.State = *s
out.State = *s
return &out, nil
}
@ -111,4 +113,4 @@ func (s *state7) AddressMap() (adt.Map, error) {
func (s *state7) GetState() interface{} {
return &s.State
}
}

View File

@ -10,8 +10,10 @@ import (
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/node/modules/dtypes"
builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin"
init8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/init"
adt8 "github.com/filecoin-project/specs-actors/v8/actors/util/adt"
)
@ -29,14 +31,14 @@ func load8(store adt.Store, root cid.Cid) (State, error) {
func make8(store adt.Store, networkName string) (State, error) {
out := state8{store: store}
s, err := init8.ConstructState(store, networkName)
if err != nil {
return nil, err
}
s, err := init8.ConstructState(store, networkName)
if err != nil {
return nil, err
}
out.State = *s
out.State = *s
return &out, nil
}
@ -111,4 +113,4 @@ func (s *state8) AddressMap() (adt.Map, error) {
func (s *state8) GetState() interface{} {
return &s.State
}
}

View File

@ -29,8 +29,9 @@ import (
builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/builtin"
"github.com/filecoin-project/lotus/chain/types"
)
@ -41,33 +42,81 @@ func init() {
return load0(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version0, "storagemarket"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load0(store, root)
})
}
builtin.RegisterActorState(builtin2.StorageMarketActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load2(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version2, "storagemarket"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load2(store, root)
})
}
builtin.RegisterActorState(builtin3.StorageMarketActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load3(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version3, "storagemarket"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load3(store, root)
})
}
builtin.RegisterActorState(builtin4.StorageMarketActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load4(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version4, "storagemarket"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load4(store, root)
})
}
builtin.RegisterActorState(builtin5.StorageMarketActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load5(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version5, "storagemarket"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load5(store, root)
})
}
builtin.RegisterActorState(builtin6.StorageMarketActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load6(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version6, "storagemarket"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load6(store, root)
})
}
builtin.RegisterActorState(builtin7.StorageMarketActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load7(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version7, "storagemarket"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load7(store, root)
})
}
builtin.RegisterActorState(builtin8.StorageMarketActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load8(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version8, "storagemarket"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load8(store, root)
})
}
}
var (
@ -76,6 +125,42 @@ var (
)
func Load(store adt.Store, act *types.Actor) (State, error) {
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
if name != "storagemarket" {
return nil, xerrors.Errorf("actor code is not storagemarket: %s", name)
}
switch av {
case actors.Version0:
return load0(store, act.Head)
case actors.Version2:
return load2(store, act.Head)
case actors.Version3:
return load3(store, act.Head)
case actors.Version4:
return load4(store, act.Head)
case actors.Version5:
return load5(store, act.Head)
case actors.Version6:
return load6(store, act.Head)
case actors.Version7:
return load7(store, act.Head)
case actors.Version8:
return load8(store, act.Head)
default:
return nil, xerrors.Errorf("unknown actor version: %d", av)
}
}
switch act.Code {
case builtin0.StorageMarketActorCodeID:
@ -133,11 +218,15 @@ func MakeState(store adt.Store, av actors.Version) (State, error) {
case actors.Version8:
return make8(store)
}
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
if c, ok := actors.GetActorCodeID(av, "storagemarket"); ok {
return c, nil
}
switch av {
case actors.Version0:
@ -210,7 +299,7 @@ type DealProposals interface {
type PublishStorageDealsParams = market0.PublishStorageDealsParams
type PublishStorageDealsReturn interface {
DealIDs() ([]abi.DealID, error)
DealIDs() ([]abi.DealID, error)
// Note that this index is based on the batch of deals that were published, NOT the DealID
IsDealValid(index uint64) (bool, error)
}
@ -247,7 +336,7 @@ func DecodePublishStorageDealsReturn(b []byte, nv network.Version) (PublishStora
case actors.Version8:
return decodePublishStorageDealsReturn8(b)
}
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
@ -263,67 +352,67 @@ type DealState struct {
}
type DealProposal struct {
PieceCID cid.Cid
PieceSize abi.PaddedPieceSize
VerifiedDeal bool
Client address.Address
Provider address.Address
Label string
StartEpoch abi.ChainEpoch
EndEpoch abi.ChainEpoch
PieceCID cid.Cid
PieceSize abi.PaddedPieceSize
VerifiedDeal bool
Client address.Address
Provider address.Address
Label string
StartEpoch abi.ChainEpoch
EndEpoch abi.ChainEpoch
StoragePricePerEpoch abi.TokenAmount
ProviderCollateral abi.TokenAmount
ClientCollateral abi.TokenAmount
ProviderCollateral abi.TokenAmount
ClientCollateral abi.TokenAmount
}
type DealStateChanges struct {
Added []DealIDState
Added []DealIDState
Modified []DealStateChange
Removed []DealIDState
Removed []DealIDState
}
type DealIDState struct {
ID abi.DealID
ID abi.DealID
Deal DealState
}
// DealStateChange is a change in deal state from -> to
type DealStateChange struct {
ID abi.DealID
ID abi.DealID
From *DealState
To *DealState
To *DealState
}
type DealProposalChanges struct {
Added []ProposalIDState
Added []ProposalIDState
Removed []ProposalIDState
}
type ProposalIDState struct {
ID abi.DealID
ID abi.DealID
Proposal DealProposal
}
func EmptyDealState() *DealState {
return &DealState{
SectorStartEpoch: -1,
SlashEpoch: -1,
SlashEpoch: -1,
LastUpdatedEpoch: -1,
}
}
// returns the earned fees and pending fees for a given deal
func (deal DealProposal) GetDealFees(height abi.ChainEpoch) (abi.TokenAmount, abi.TokenAmount) {
tf := big.Mul(deal.StoragePricePerEpoch, big.NewInt(int64(deal.EndEpoch-deal.StartEpoch)))
tf := big.Mul(deal.StoragePricePerEpoch, big.NewInt(int64(deal.EndEpoch-deal.StartEpoch)))
ef := big.Mul(deal.StoragePricePerEpoch, big.NewInt(int64(height-deal.StartEpoch)))
if ef.LessThan(big.Zero()) {
ef = big.Zero()
}
ef := big.Mul(deal.StoragePricePerEpoch, big.NewInt(int64(height-deal.StartEpoch)))
if ef.LessThan(big.Zero()) {
ef = big.Zero()
}
if ef.GreaterThan(tf) {
ef = tf
}
if ef.GreaterThan(tf) {
ef = tf
}
return ef, big.Sub(tf, ef)
return ef, big.Sub(tf, ef)
}

View File

@ -29,19 +29,19 @@ func load0(store adt.Store, root cid.Cid) (State, error) {
func make0(store adt.Store) (State, error) {
out := state0{store: store}
ea, err := adt0.MakeEmptyArray(store).Root()
if err != nil {
return nil, err
}
ea, err := adt0.MakeEmptyArray(store).Root()
if err != nil {
return nil, err
}
em, err := adt0.MakeEmptyMap(store).Root()
if err != nil {
return nil, err
}
out.State = *market0.ConstructState(ea, em, em)
em, err := adt0.MakeEmptyMap(store).Root()
if err != nil {
return nil, err
}
out.State = *market0.ConstructState(ea, em, em)
return &out, nil
}
@ -247,12 +247,12 @@ type publishStorageDealsReturn0 struct {
}
func (r *publishStorageDealsReturn0) IsDealValid(index uint64) (bool, error) {
// PublishStorageDeals only succeeded if all deals were valid in this version of actors
return true, nil
// PublishStorageDeals only succeeded if all deals were valid in this version of actors
return true, nil
}
func (r *publishStorageDealsReturn0) DealIDs() ([]abi.DealID, error) {
return r.IDs, nil
return r.IDs, nil
}

View File

@ -29,19 +29,19 @@ func load2(store adt.Store, root cid.Cid) (State, error) {
func make2(store adt.Store) (State, error) {
out := state2{store: store}
ea, err := adt2.MakeEmptyArray(store).Root()
if err != nil {
return nil, err
}
ea, err := adt2.MakeEmptyArray(store).Root()
if err != nil {
return nil, err
}
em, err := adt2.MakeEmptyMap(store).Root()
if err != nil {
return nil, err
}
out.State = *market2.ConstructState(ea, em, em)
em, err := adt2.MakeEmptyMap(store).Root()
if err != nil {
return nil, err
}
out.State = *market2.ConstructState(ea, em, em)
return &out, nil
}
@ -247,12 +247,12 @@ type publishStorageDealsReturn2 struct {
}
func (r *publishStorageDealsReturn2) IsDealValid(index uint64) (bool, error) {
// PublishStorageDeals only succeeded if all deals were valid in this version of actors
return true, nil
// PublishStorageDeals only succeeded if all deals were valid in this version of actors
return true, nil
}
func (r *publishStorageDealsReturn2) DealIDs() ([]abi.DealID, error) {
return r.IDs, nil
return r.IDs, nil
}

View File

@ -29,14 +29,14 @@ func load3(store adt.Store, root cid.Cid) (State, error) {
func make3(store adt.Store) (State, error) {
out := state3{store: store}
s, err := market3.ConstructState(store)
if err != nil {
return nil, err
}
s, err := market3.ConstructState(store)
if err != nil {
return nil, err
}
out.State = *s
out.State = *s
return &out, nil
}
@ -242,12 +242,12 @@ type publishStorageDealsReturn3 struct {
}
func (r *publishStorageDealsReturn3) IsDealValid(index uint64) (bool, error) {
// PublishStorageDeals only succeeded if all deals were valid in this version of actors
return true, nil
// PublishStorageDeals only succeeded if all deals were valid in this version of actors
return true, nil
}
func (r *publishStorageDealsReturn3) DealIDs() ([]abi.DealID, error) {
return r.IDs, nil
return r.IDs, nil
}

View File

@ -29,14 +29,14 @@ func load4(store adt.Store, root cid.Cid) (State, error) {
func make4(store adt.Store) (State, error) {
out := state4{store: store}
s, err := market4.ConstructState(store)
if err != nil {
return nil, err
}
s, err := market4.ConstructState(store)
if err != nil {
return nil, err
}
out.State = *s
out.State = *s
return &out, nil
}
@ -242,12 +242,12 @@ type publishStorageDealsReturn4 struct {
}
func (r *publishStorageDealsReturn4) IsDealValid(index uint64) (bool, error) {
// PublishStorageDeals only succeeded if all deals were valid in this version of actors
return true, nil
// PublishStorageDeals only succeeded if all deals were valid in this version of actors
return true, nil
}
func (r *publishStorageDealsReturn4) DealIDs() ([]abi.DealID, error) {
return r.IDs, nil
return r.IDs, nil
}

View File

@ -29,14 +29,14 @@ func load5(store adt.Store, root cid.Cid) (State, error) {
func make5(store adt.Store) (State, error) {
out := state5{store: store}
s, err := market5.ConstructState(store)
if err != nil {
return nil, err
}
s, err := market5.ConstructState(store)
if err != nil {
return nil, err
}
out.State = *s
out.State = *s
return &out, nil
}
@ -242,12 +242,12 @@ type publishStorageDealsReturn5 struct {
}
func (r *publishStorageDealsReturn5) IsDealValid(index uint64) (bool, error) {
// PublishStorageDeals only succeeded if all deals were valid in this version of actors
return true, nil
// PublishStorageDeals only succeeded if all deals were valid in this version of actors
return true, nil
}
func (r *publishStorageDealsReturn5) DealIDs() ([]abi.DealID, error) {
return r.IDs, nil
return r.IDs, nil
}

View File

@ -29,14 +29,14 @@ func load6(store adt.Store, root cid.Cid) (State, error) {
func make6(store adt.Store) (State, error) {
out := state6{store: store}
s, err := market6.ConstructState(store)
if err != nil {
return nil, err
}
s, err := market6.ConstructState(store)
if err != nil {
return nil, err
}
out.State = *s
out.State = *s
return &out, nil
}
@ -242,11 +242,11 @@ type publishStorageDealsReturn6 struct {
}
func (r *publishStorageDealsReturn6) IsDealValid(index uint64) (bool, error) {
return r.ValidDeals.IsSet(index)
return r.ValidDeals.IsSet(index)
}
func (r *publishStorageDealsReturn6) DealIDs() ([]abi.DealID, error) {
return r.IDs, nil
return r.IDs, nil
}

View File

@ -29,14 +29,14 @@ func load7(store adt.Store, root cid.Cid) (State, error) {
func make7(store adt.Store) (State, error) {
out := state7{store: store}
s, err := market7.ConstructState(store)
if err != nil {
return nil, err
}
s, err := market7.ConstructState(store)
if err != nil {
return nil, err
}
out.State = *s
out.State = *s
return &out, nil
}
@ -242,11 +242,11 @@ type publishStorageDealsReturn7 struct {
}
func (r *publishStorageDealsReturn7) IsDealValid(index uint64) (bool, error) {
return r.ValidDeals.IsSet(index)
return r.ValidDeals.IsSet(index)
}
func (r *publishStorageDealsReturn7) DealIDs() ([]abi.DealID, error) {
return r.IDs, nil
return r.IDs, nil
}

View File

@ -29,14 +29,14 @@ func load8(store adt.Store, root cid.Cid) (State, error) {
func make8(store adt.Store) (State, error) {
out := state8{store: store}
s, err := market8.ConstructState(store)
if err != nil {
return nil, err
}
s, err := market8.ConstructState(store)
if err != nil {
return nil, err
}
out.State = *s
out.State = *s
return &out, nil
}
@ -242,11 +242,11 @@ type publishStorageDealsReturn8 struct {
}
func (r *publishStorageDealsReturn8) IsDealValid(index uint64) (bool, error) {
return r.ValidDeals.IsSet(index)
return r.ValidDeals.IsSet(index)
}
func (r *publishStorageDealsReturn8) DealIDs() ([]abi.DealID, error) {
return r.IDs, nil
return r.IDs, nil
}

View File

@ -40,6 +40,7 @@ import (
builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin"
)
func init() {
@ -48,34 +49,82 @@ func init() {
return load0(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version0, "storageminer"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load0(store, root)
})
}
builtin.RegisterActorState(builtin2.StorageMinerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load2(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version2, "storageminer"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load2(store, root)
})
}
builtin.RegisterActorState(builtin3.StorageMinerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load3(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version3, "storageminer"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load3(store, root)
})
}
builtin.RegisterActorState(builtin4.StorageMinerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load4(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version4, "storageminer"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load4(store, root)
})
}
builtin.RegisterActorState(builtin5.StorageMinerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load5(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version5, "storageminer"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load5(store, root)
})
}
builtin.RegisterActorState(builtin6.StorageMinerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load6(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version6, "storageminer"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load6(store, root)
})
}
builtin.RegisterActorState(builtin7.StorageMinerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load7(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version7, "storageminer"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load7(store, root)
})
}
builtin.RegisterActorState(builtin8.StorageMinerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load8(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version8, "storageminer"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load8(store, root)
})
}
}
var Methods = builtin8.MethodsMiner
@ -95,6 +144,42 @@ var DeclarationsMax = miner2.DeclarationsMax
var AddressedSectorsMax = miner2.AddressedSectorsMax
func Load(store adt.Store, act *types.Actor) (State, error) {
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
if name != "storageminer" {
return nil, xerrors.Errorf("actor code is not storageminer: %s", name)
}
switch av {
case actors.Version0:
return load0(store, act.Head)
case actors.Version2:
return load2(store, act.Head)
case actors.Version3:
return load3(store, act.Head)
case actors.Version4:
return load4(store, act.Head)
case actors.Version5:
return load5(store, act.Head)
case actors.Version6:
return load6(store, act.Head)
case actors.Version7:
return load7(store, act.Head)
case actors.Version8:
return load8(store, act.Head)
default:
return nil, xerrors.Errorf("unknown actor version: %d", av)
}
}
switch act.Code {
case builtin0.StorageMinerActorCodeID:
@ -121,7 +206,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
case builtin8.StorageMinerActorCodeID:
return load8(store, act.Head)
}
}
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
@ -152,11 +237,15 @@ func MakeState(store adt.Store, av actors.Version) (State, error) {
case actors.Version8:
return make8(store)
}
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
if c, ok := actors.GetActorCodeID(av, "storageminer"); ok {
return c, nil
}
switch av {
case actors.Version0:
@ -207,8 +296,8 @@ type State interface {
LoadSectors(sectorNos *bitfield.BitField) ([]*SectorOnChainInfo, error)
NumLiveSectors() (uint64, error)
IsAllocated(abi.SectorNumber) (bool, error)
// UnallocatedSectorNumbers returns up to count unallocated sector numbers (or less than
// count if there aren't enough).
// UnallocatedSectorNumbers returns up to count unallocated sector numbers (or less than
// count if there aren't enough).
UnallocatedSectorNumbers(count int) ([]abi.SectorNumber, error)
GetAllocatedSectors() (*bitfield.BitField, error)

View File

@ -18,6 +18,7 @@ import (
"github.com/filecoin-project/lotus/chain/actors/adt"
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
adt0 "github.com/filecoin-project/specs-actors/actors/util/adt"
)
@ -135,10 +136,10 @@ func (s *state0) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, e
return nil, err
}
// NOTE: this can be optimized significantly.
// 1. If the sector is non-faulty, it will either expire on-time (can be
// 1. If the sector is non-faulty, it will either expire on-time (can be
// learned from the sector info), or in the next quantized expiration
// epoch (i.e., the first element in the partition's expiration queue.
// 2. If it's faulty, it will expire early within the first 14 entries
// 2. If it's faulty, it will expire early within the first 14 entries
// of the expiration queue.
stopErr := errors.New("stop")
@ -209,7 +210,7 @@ func (s *state0) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOn
}
func (s *state0) ForEachPrecommittedSector(cb func(SectorPreCommitOnChainInfo) error) error {
precommitted, err := adt0.AsMap(s.store, s.State.PreCommittedSectors)
precommitted, err := adt0.AsMap(s.store, s.State.PreCommittedSectors)
if err != nil {
return err
}
@ -288,7 +289,7 @@ func (s *state0) UnallocatedSectorNumbers(count int) ([]abi.SectorNumber, error)
}
unallocatedRuns, err := rle.Subtract(
&rle.RunSliceIterator{Runs: []rle.Run{{Val: true, Len: abi.MaxSectorNumber}}},
&rle.RunSliceIterator{Runs: []rle.Run{ {Val: true, Len: abi.MaxSectorNumber} }},
allocatedRuns,
)
if err != nil {
@ -443,10 +444,10 @@ func (s *state0) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreC
}
func (s *state0) EraseAllUnproven() error {
// field doesn't exist until v2
return nil
// field doesn't exist until v2
return nil
}
func (d *deadline0) LoadPartition(idx uint64) (Partition, error) {
@ -518,6 +519,7 @@ func fromV0SectorOnChainInfo(v0 miner0.SectorOnChainInfo) SectorOnChainInfo {
InitialPledge: v0.InitialPledge,
ExpectedDayReward: v0.ExpectedDayReward,
ExpectedStoragePledge: v0.ExpectedStoragePledge,
}
return info
}

View File

@ -16,6 +16,7 @@ import (
"github.com/filecoin-project/lotus/chain/actors/adt"
miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner"
adt2 "github.com/filecoin-project/specs-actors/v2/actors/util/adt"
)
@ -133,10 +134,10 @@ func (s *state2) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, e
return nil, err
}
// NOTE: this can be optimized significantly.
// 1. If the sector is non-faulty, it will either expire on-time (can be
// 1. If the sector is non-faulty, it will either expire on-time (can be
// learned from the sector info), or in the next quantized expiration
// epoch (i.e., the first element in the partition's expiration queue.
// 2. If it's faulty, it will expire early within the first 14 entries
// 2. If it's faulty, it will expire early within the first 14 entries
// of the expiration queue.
stopErr := errors.New("stop")
@ -207,7 +208,7 @@ func (s *state2) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOn
}
func (s *state2) ForEachPrecommittedSector(cb func(SectorPreCommitOnChainInfo) error) error {
precommitted, err := adt2.AsMap(s.store, s.State.PreCommittedSectors)
precommitted, err := adt2.AsMap(s.store, s.State.PreCommittedSectors)
if err != nil {
return err
}
@ -286,7 +287,7 @@ func (s *state2) UnallocatedSectorNumbers(count int) ([]abi.SectorNumber, error)
}
unallocatedRuns, err := rle.Subtract(
&rle.RunSliceIterator{Runs: []rle.Run{{Val: true, Len: abi.MaxSectorNumber}}},
&rle.RunSliceIterator{Runs: []rle.Run{ {Val: true, Len: abi.MaxSectorNumber} }},
allocatedRuns,
)
if err != nil {
@ -441,42 +442,42 @@ func (s *state2) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreC
}
func (s *state2) EraseAllUnproven() error {
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
return err
}
err = dls.ForEach(s.store, func(dindx uint64, dl *miner2.Deadline) error {
ps, err := dl.PartitionsArray(s.store)
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
return err
}
var part miner2.Partition
err = ps.ForEach(&part, func(pindx int64) error {
_ = part.ActivateUnproven()
err = ps.Set(uint64(pindx), &part)
return nil
err = dls.ForEach(s.store, func(dindx uint64, dl *miner2.Deadline) error {
ps, err := dl.PartitionsArray(s.store)
if err != nil {
return err
}
var part miner2.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
}
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)
return s.State.SaveDeadlines(s.store, dls)
}
func (d *deadline2) LoadPartition(idx uint64) (Partition, error) {
@ -548,6 +549,7 @@ func fromV2SectorOnChainInfo(v2 miner2.SectorOnChainInfo) SectorOnChainInfo {
InitialPledge: v2.InitialPledge,
ExpectedDayReward: v2.ExpectedDayReward,
ExpectedStoragePledge: v2.ExpectedStoragePledge,
}
return info
}

View File

@ -16,6 +16,7 @@ import (
"github.com/filecoin-project/lotus/chain/actors/adt"
builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin"
miner3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/miner"
@ -135,10 +136,10 @@ func (s *state3) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, e
return nil, err
}
// NOTE: this can be optimized significantly.
// 1. If the sector is non-faulty, it will either expire on-time (can be
// 1. If the sector is non-faulty, it will either expire on-time (can be
// learned from the sector info), or in the next quantized expiration
// epoch (i.e., the first element in the partition's expiration queue.
// 2. If it's faulty, it will expire early within the first 14 entries
// 2. If it's faulty, it will expire early within the first 14 entries
// of the expiration queue.
stopErr := errors.New("stop")
@ -209,7 +210,7 @@ func (s *state3) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOn
}
func (s *state3) ForEachPrecommittedSector(cb func(SectorPreCommitOnChainInfo) error) error {
precommitted, err := adt3.AsMap(s.store, s.State.PreCommittedSectors, builtin3.DefaultHamtBitwidth)
precommitted, err := adt3.AsMap(s.store, s.State.PreCommittedSectors, builtin3.DefaultHamtBitwidth)
if err != nil {
return err
}
@ -288,7 +289,7 @@ func (s *state3) UnallocatedSectorNumbers(count int) ([]abi.SectorNumber, error)
}
unallocatedRuns, err := rle.Subtract(
&rle.RunSliceIterator{Runs: []rle.Run{{Val: true, Len: abi.MaxSectorNumber}}},
&rle.RunSliceIterator{Runs: []rle.Run{ {Val: true, Len: abi.MaxSectorNumber} }},
allocatedRuns,
)
if err != nil {
@ -438,42 +439,42 @@ func (s *state3) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreC
}
func (s *state3) EraseAllUnproven() error {
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
return err
}
err = dls.ForEach(s.store, func(dindx uint64, dl *miner3.Deadline) error {
ps, err := dl.PartitionsArray(s.store)
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
return err
}
var part miner3.Partition
err = ps.ForEach(&part, func(pindx int64) error {
_ = part.ActivateUnproven()
err = ps.Set(uint64(pindx), &part)
return nil
err = dls.ForEach(s.store, func(dindx uint64, dl *miner3.Deadline) error {
ps, err := dl.PartitionsArray(s.store)
if err != nil {
return err
}
var part miner3.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
}
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)
return s.State.SaveDeadlines(s.store, dls)
}
func (d *deadline3) LoadPartition(idx uint64) (Partition, error) {
@ -549,6 +550,7 @@ func fromV3SectorOnChainInfo(v3 miner3.SectorOnChainInfo) SectorOnChainInfo {
InitialPledge: v3.InitialPledge,
ExpectedDayReward: v3.ExpectedDayReward,
ExpectedStoragePledge: v3.ExpectedStoragePledge,
}
return info
}

View File

@ -16,6 +16,7 @@ import (
"github.com/filecoin-project/lotus/chain/actors/adt"
builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin"
miner4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/miner"
@ -135,10 +136,10 @@ func (s *state4) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, e
return nil, err
}
// NOTE: this can be optimized significantly.
// 1. If the sector is non-faulty, it will either expire on-time (can be
// 1. If the sector is non-faulty, it will either expire on-time (can be
// learned from the sector info), or in the next quantized expiration
// epoch (i.e., the first element in the partition's expiration queue.
// 2. If it's faulty, it will expire early within the first 14 entries
// 2. If it's faulty, it will expire early within the first 14 entries
// of the expiration queue.
stopErr := errors.New("stop")
@ -209,7 +210,7 @@ func (s *state4) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOn
}
func (s *state4) ForEachPrecommittedSector(cb func(SectorPreCommitOnChainInfo) error) error {
precommitted, err := adt4.AsMap(s.store, s.State.PreCommittedSectors, builtin4.DefaultHamtBitwidth)
precommitted, err := adt4.AsMap(s.store, s.State.PreCommittedSectors, builtin4.DefaultHamtBitwidth)
if err != nil {
return err
}
@ -288,7 +289,7 @@ func (s *state4) UnallocatedSectorNumbers(count int) ([]abi.SectorNumber, error)
}
unallocatedRuns, err := rle.Subtract(
&rle.RunSliceIterator{Runs: []rle.Run{{Val: true, Len: abi.MaxSectorNumber}}},
&rle.RunSliceIterator{Runs: []rle.Run{ {Val: true, Len: abi.MaxSectorNumber} }},
allocatedRuns,
)
if err != nil {
@ -438,42 +439,42 @@ func (s *state4) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreC
}
func (s *state4) EraseAllUnproven() error {
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
return err
}
err = dls.ForEach(s.store, func(dindx uint64, dl *miner4.Deadline) error {
ps, err := dl.PartitionsArray(s.store)
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
return err
}
var part miner4.Partition
err = ps.ForEach(&part, func(pindx int64) error {
_ = part.ActivateUnproven()
err = ps.Set(uint64(pindx), &part)
return nil
err = dls.ForEach(s.store, func(dindx uint64, dl *miner4.Deadline) error {
ps, err := dl.PartitionsArray(s.store)
if err != nil {
return err
}
var part miner4.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
}
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)
return s.State.SaveDeadlines(s.store, dls)
}
func (d *deadline4) LoadPartition(idx uint64) (Partition, error) {
@ -549,6 +550,7 @@ func fromV4SectorOnChainInfo(v4 miner4.SectorOnChainInfo) SectorOnChainInfo {
InitialPledge: v4.InitialPledge,
ExpectedDayReward: v4.ExpectedDayReward,
ExpectedStoragePledge: v4.ExpectedStoragePledge,
}
return info
}

View File

@ -16,6 +16,7 @@ import (
"github.com/filecoin-project/lotus/chain/actors/adt"
builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin"
miner5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/miner"
@ -135,10 +136,10 @@ func (s *state5) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, e
return nil, err
}
// NOTE: this can be optimized significantly.
// 1. If the sector is non-faulty, it will either expire on-time (can be
// 1. If the sector is non-faulty, it will either expire on-time (can be
// learned from the sector info), or in the next quantized expiration
// epoch (i.e., the first element in the partition's expiration queue.
// 2. If it's faulty, it will expire early within the first 14 entries
// 2. If it's faulty, it will expire early within the first 14 entries
// of the expiration queue.
stopErr := errors.New("stop")
@ -209,7 +210,7 @@ func (s *state5) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOn
}
func (s *state5) ForEachPrecommittedSector(cb func(SectorPreCommitOnChainInfo) error) error {
precommitted, err := adt5.AsMap(s.store, s.State.PreCommittedSectors, builtin5.DefaultHamtBitwidth)
precommitted, err := adt5.AsMap(s.store, s.State.PreCommittedSectors, builtin5.DefaultHamtBitwidth)
if err != nil {
return err
}
@ -288,7 +289,7 @@ func (s *state5) UnallocatedSectorNumbers(count int) ([]abi.SectorNumber, error)
}
unallocatedRuns, err := rle.Subtract(
&rle.RunSliceIterator{Runs: []rle.Run{{Val: true, Len: abi.MaxSectorNumber}}},
&rle.RunSliceIterator{Runs: []rle.Run{ {Val: true, Len: abi.MaxSectorNumber} }},
allocatedRuns,
)
if err != nil {
@ -438,42 +439,42 @@ func (s *state5) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreC
}
func (s *state5) EraseAllUnproven() error {
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
return err
}
err = dls.ForEach(s.store, func(dindx uint64, dl *miner5.Deadline) error {
ps, err := dl.PartitionsArray(s.store)
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
return err
}
var part miner5.Partition
err = ps.ForEach(&part, func(pindx int64) error {
_ = part.ActivateUnproven()
err = ps.Set(uint64(pindx), &part)
return nil
err = dls.ForEach(s.store, func(dindx uint64, dl *miner5.Deadline) error {
ps, err := dl.PartitionsArray(s.store)
if err != nil {
return err
}
var part miner5.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
}
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)
return s.State.SaveDeadlines(s.store, dls)
}
func (d *deadline5) LoadPartition(idx uint64) (Partition, error) {
@ -549,6 +550,7 @@ func fromV5SectorOnChainInfo(v5 miner5.SectorOnChainInfo) SectorOnChainInfo {
InitialPledge: v5.InitialPledge,
ExpectedDayReward: v5.ExpectedDayReward,
ExpectedStoragePledge: v5.ExpectedStoragePledge,
}
return info
}

View File

@ -16,6 +16,7 @@ import (
"github.com/filecoin-project/lotus/chain/actors/adt"
builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin"
miner6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/miner"
@ -135,10 +136,10 @@ func (s *state6) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, e
return nil, err
}
// NOTE: this can be optimized significantly.
// 1. If the sector is non-faulty, it will either expire on-time (can be
// 1. If the sector is non-faulty, it will either expire on-time (can be
// learned from the sector info), or in the next quantized expiration
// epoch (i.e., the first element in the partition's expiration queue.
// 2. If it's faulty, it will expire early within the first 42 entries
// 2. If it's faulty, it will expire early within the first 42 entries
// of the expiration queue.
stopErr := errors.New("stop")
@ -209,7 +210,7 @@ func (s *state6) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOn
}
func (s *state6) ForEachPrecommittedSector(cb func(SectorPreCommitOnChainInfo) error) error {
precommitted, err := adt6.AsMap(s.store, s.State.PreCommittedSectors, builtin6.DefaultHamtBitwidth)
precommitted, err := adt6.AsMap(s.store, s.State.PreCommittedSectors, builtin6.DefaultHamtBitwidth)
if err != nil {
return err
}
@ -288,7 +289,7 @@ func (s *state6) UnallocatedSectorNumbers(count int) ([]abi.SectorNumber, error)
}
unallocatedRuns, err := rle.Subtract(
&rle.RunSliceIterator{Runs: []rle.Run{{Val: true, Len: abi.MaxSectorNumber}}},
&rle.RunSliceIterator{Runs: []rle.Run{ {Val: true, Len: abi.MaxSectorNumber} }},
allocatedRuns,
)
if err != nil {
@ -438,42 +439,42 @@ func (s *state6) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreC
}
func (s *state6) EraseAllUnproven() error {
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
return err
}
err = dls.ForEach(s.store, func(dindx uint64, dl *miner6.Deadline) error {
ps, err := dl.PartitionsArray(s.store)
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
return err
}
var part miner6.Partition
err = ps.ForEach(&part, func(pindx int64) error {
_ = part.ActivateUnproven()
err = ps.Set(uint64(pindx), &part)
return nil
err = dls.ForEach(s.store, func(dindx uint64, dl *miner6.Deadline) error {
ps, err := dl.PartitionsArray(s.store)
if err != nil {
return err
}
var part miner6.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
}
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)
return s.State.SaveDeadlines(s.store, dls)
}
func (d *deadline6) LoadPartition(idx uint64) (Partition, error) {
@ -549,6 +550,7 @@ func fromV6SectorOnChainInfo(v6 miner6.SectorOnChainInfo) SectorOnChainInfo {
InitialPledge: v6.InitialPledge,
ExpectedDayReward: v6.ExpectedDayReward,
ExpectedStoragePledge: v6.ExpectedStoragePledge,
}
return info
}

View File

@ -16,6 +16,7 @@ import (
"github.com/filecoin-project/lotus/chain/actors/adt"
builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
miner7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/miner"
@ -135,9 +136,9 @@ func (s *state7) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, e
return nil, err
}
// NOTE: this can be optimized significantly.
// 1. If the sector is non-faulty, it will expire on-time (can be
// 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
// 2. If it's faulty, it will expire early within the first 42 entries
// of the expiration queue.
stopErr := errors.New("stop")
@ -208,7 +209,7 @@ func (s *state7) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOn
}
func (s *state7) ForEachPrecommittedSector(cb func(SectorPreCommitOnChainInfo) error) error {
precommitted, err := adt7.AsMap(s.store, s.State.PreCommittedSectors, builtin7.DefaultHamtBitwidth)
precommitted, err := adt7.AsMap(s.store, s.State.PreCommittedSectors, builtin7.DefaultHamtBitwidth)
if err != nil {
return err
}
@ -287,7 +288,7 @@ func (s *state7) UnallocatedSectorNumbers(count int) ([]abi.SectorNumber, error)
}
unallocatedRuns, err := rle.Subtract(
&rle.RunSliceIterator{Runs: []rle.Run{{Val: true, Len: abi.MaxSectorNumber}}},
&rle.RunSliceIterator{Runs: []rle.Run{ {Val: true, Len: abi.MaxSectorNumber} }},
allocatedRuns,
)
if err != nil {
@ -437,42 +438,42 @@ func (s *state7) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreC
}
func (s *state7) EraseAllUnproven() error {
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
return err
}
err = dls.ForEach(s.store, func(dindx uint64, dl *miner7.Deadline) error {
ps, err := dl.PartitionsArray(s.store)
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
return err
}
var part miner7.Partition
err = ps.ForEach(&part, func(pindx int64) error {
_ = part.ActivateUnproven()
err = ps.Set(uint64(pindx), &part)
return nil
err = dls.ForEach(s.store, func(dindx uint64, dl *miner7.Deadline) error {
ps, err := dl.PartitionsArray(s.store)
if err != nil {
return err
}
var part miner7.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
}
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)
return s.State.SaveDeadlines(s.store, dls)
}
func (d *deadline7) LoadPartition(idx uint64) (Partition, error) {
@ -548,8 +549,9 @@ func fromV7SectorOnChainInfo(v7 miner7.SectorOnChainInfo) SectorOnChainInfo {
InitialPledge: v7.InitialPledge,
ExpectedDayReward: v7.ExpectedDayReward,
ExpectedStoragePledge: v7.ExpectedStoragePledge,
SectorKeyCID: v7.SectorKeyCID,
}
return info
}

View File

@ -16,6 +16,7 @@ import (
"github.com/filecoin-project/lotus/chain/actors/adt"
builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin"
miner8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/miner"
@ -135,9 +136,9 @@ func (s *state8) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, e
return nil, err
}
// NOTE: this can be optimized significantly.
// 1. If the sector is non-faulty, it will expire on-time (can be
// 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
// 2. If it's faulty, it will expire early within the first 42 entries
// of the expiration queue.
stopErr := errors.New("stop")
@ -208,7 +209,7 @@ func (s *state8) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOn
}
func (s *state8) ForEachPrecommittedSector(cb func(SectorPreCommitOnChainInfo) error) error {
precommitted, err := adt8.AsMap(s.store, s.State.PreCommittedSectors, builtin8.DefaultHamtBitwidth)
precommitted, err := adt8.AsMap(s.store, s.State.PreCommittedSectors, builtin8.DefaultHamtBitwidth)
if err != nil {
return err
}
@ -287,7 +288,7 @@ func (s *state8) UnallocatedSectorNumbers(count int) ([]abi.SectorNumber, error)
}
unallocatedRuns, err := rle.Subtract(
&rle.RunSliceIterator{Runs: []rle.Run{{Val: true, Len: abi.MaxSectorNumber}}},
&rle.RunSliceIterator{Runs: []rle.Run{ {Val: true, Len: abi.MaxSectorNumber} }},
allocatedRuns,
)
if err != nil {
@ -437,42 +438,42 @@ func (s *state8) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreC
}
func (s *state8) EraseAllUnproven() error {
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
return err
}
err = dls.ForEach(s.store, func(dindx uint64, dl *miner8.Deadline) error {
ps, err := dl.PartitionsArray(s.store)
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
return err
}
var part miner8.Partition
err = ps.ForEach(&part, func(pindx int64) error {
_ = part.ActivateUnproven()
err = ps.Set(uint64(pindx), &part)
return nil
err = dls.ForEach(s.store, func(dindx uint64, dl *miner8.Deadline) error {
ps, err := dl.PartitionsArray(s.store)
if err != nil {
return err
}
var part miner8.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
}
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)
return s.State.SaveDeadlines(s.store, dls)
}
func (d *deadline8) LoadPartition(idx uint64) (Partition, error) {
@ -548,8 +549,9 @@ func fromV8SectorOnChainInfo(v8 miner8.SectorOnChainInfo) SectorOnChainInfo {
InitialPledge: v8.InitialPledge,
ExpectedDayReward: v8.ExpectedDayReward,
ExpectedStoragePledge: v8.ExpectedStoragePledge,
SectorKeyCID: v8.SectorKeyCID,
}
return info
}

View File

@ -73,6 +73,8 @@ func (m message0) Create(
}, nil
}
func (m message0) Propose(msig, to address.Address, amt abi.TokenAmount,
method abi.MethodNum, params []byte) (*types.Message, error) {
@ -140,3 +142,4 @@ func (m message0) Cancel(msig address.Address, txID uint64, hashData *ProposalHa
Params: enc,
}, nil
}

View File

@ -69,3 +69,5 @@ func (m message2) Create(
Value: initialAmount,
}, nil
}

View File

@ -69,3 +69,5 @@ func (m message3) Create(
Value: initialAmount,
}, nil
}

View File

@ -69,3 +69,5 @@ func (m message4) Create(
Value: initialAmount,
}, nil
}

View File

@ -69,3 +69,5 @@ func (m message5) Create(
Value: initialAmount,
}, nil
}

View File

@ -69,3 +69,5 @@ func (m message6) Create(
Value: initialAmount,
}, nil
}

View File

@ -69,3 +69,5 @@ func (m message7) Create(
Value: initialAmount,
}, nil
}

View File

@ -69,3 +69,5 @@ func (m message8) Create(
Value: initialAmount,
}, nil
}

View File

@ -31,6 +31,7 @@ import (
builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/actors/builtin"
@ -43,36 +44,120 @@ func init() {
return load0(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version0, "multisig"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load0(store, root)
})
}
builtin.RegisterActorState(builtin2.MultisigActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load2(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version2, "multisig"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load2(store, root)
})
}
builtin.RegisterActorState(builtin3.MultisigActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load3(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version3, "multisig"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load3(store, root)
})
}
builtin.RegisterActorState(builtin4.MultisigActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load4(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version4, "multisig"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load4(store, root)
})
}
builtin.RegisterActorState(builtin5.MultisigActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load5(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version5, "multisig"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load5(store, root)
})
}
builtin.RegisterActorState(builtin6.MultisigActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load6(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version6, "multisig"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load6(store, root)
})
}
builtin.RegisterActorState(builtin7.MultisigActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load7(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version7, "multisig"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load7(store, root)
})
}
builtin.RegisterActorState(builtin8.MultisigActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load8(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version8, "multisig"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load8(store, root)
})
}
}
func Load(store adt.Store, act *types.Actor) (State, error) {
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
if name != "multisig" {
return nil, xerrors.Errorf("actor code is not multisig: %s", name)
}
switch av {
case actors.Version0:
return load0(store, act.Head)
case actors.Version2:
return load2(store, act.Head)
case actors.Version3:
return load3(store, act.Head)
case actors.Version4:
return load4(store, act.Head)
case actors.Version5:
return load5(store, act.Head)
case actors.Version6:
return load6(store, act.Head)
case actors.Version7:
return load7(store, act.Head)
case actors.Version8:
return load8(store, act.Head)
default:
return nil, xerrors.Errorf("unknown actor version: %d", av)
}
}
switch act.Code {
case builtin0.MultisigActorCodeID:
@ -130,11 +215,15 @@ func MakeState(store adt.Store, av actors.Version, signers []address.Address, th
case actors.Version8:
return make8(store, signers, threshold, startEpoch, unlockDuration, initialBalance)
}
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
if c, ok := actors.GetActorCodeID(av, "multisig"); ok {
return c, nil
}
switch av {
case actors.Version0:

View File

@ -14,6 +14,7 @@ import (
"github.com/filecoin-project/lotus/chain/actors/adt"
msig0 "github.com/filecoin-project/specs-actors/actors/builtin/multisig"
)
@ -36,14 +37,14 @@ func make0(store adt.Store, signers []address.Address, threshold uint64, startEp
out.State.StartEpoch = startEpoch
out.State.UnlockDuration = unlockDuration
out.State.InitialBalance = initialBalance
em, err := adt0.MakeEmptyMap(store).Root()
if err != nil {
return nil, err
}
em, err := adt0.MakeEmptyMap(store).Root()
if err != nil {
return nil, err
}
out.State.PendingTxns = em
out.State.PendingTxns = em
return &out, nil
}

View File

@ -14,6 +14,7 @@ import (
"github.com/filecoin-project/lotus/chain/actors/adt"
msig2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/multisig"
)
@ -36,14 +37,14 @@ func make2(store adt.Store, signers []address.Address, threshold uint64, startEp
out.State.StartEpoch = startEpoch
out.State.UnlockDuration = unlockDuration
out.State.InitialBalance = initialBalance
em, err := adt2.MakeEmptyMap(store).Root()
if err != nil {
return nil, err
}
em, err := adt2.MakeEmptyMap(store).Root()
if err != nil {
return nil, err
}
out.State.PendingTxns = em
out.State.PendingTxns = em
return &out, nil
}

View File

@ -14,6 +14,7 @@ import (
"github.com/filecoin-project/lotus/chain/actors/adt"
builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin"
msig3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/multisig"
@ -38,14 +39,14 @@ func make3(store adt.Store, signers []address.Address, threshold uint64, startEp
out.State.StartEpoch = startEpoch
out.State.UnlockDuration = unlockDuration
out.State.InitialBalance = initialBalance
em, err := adt3.StoreEmptyMap(store, builtin3.DefaultHamtBitwidth)
if err != nil {
return nil, err
}
em, err := adt3.StoreEmptyMap(store, builtin3.DefaultHamtBitwidth)
if err != nil {
return nil, err
}
out.State.PendingTxns = em
out.State.PendingTxns = em
return &out, nil
}

View File

@ -14,6 +14,7 @@ import (
"github.com/filecoin-project/lotus/chain/actors/adt"
builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin"
msig4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/multisig"
@ -38,14 +39,14 @@ func make4(store adt.Store, signers []address.Address, threshold uint64, startEp
out.State.StartEpoch = startEpoch
out.State.UnlockDuration = unlockDuration
out.State.InitialBalance = initialBalance
em, err := adt4.StoreEmptyMap(store, builtin4.DefaultHamtBitwidth)
if err != nil {
return nil, err
}
em, err := adt4.StoreEmptyMap(store, builtin4.DefaultHamtBitwidth)
if err != nil {
return nil, err
}
out.State.PendingTxns = em
out.State.PendingTxns = em
return &out, nil
}

View File

@ -14,6 +14,7 @@ import (
"github.com/filecoin-project/lotus/chain/actors/adt"
builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin"
msig5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/multisig"
@ -38,14 +39,14 @@ func make5(store adt.Store, signers []address.Address, threshold uint64, startEp
out.State.StartEpoch = startEpoch
out.State.UnlockDuration = unlockDuration
out.State.InitialBalance = initialBalance
em, err := adt5.StoreEmptyMap(store, builtin5.DefaultHamtBitwidth)
if err != nil {
return nil, err
}
em, err := adt5.StoreEmptyMap(store, builtin5.DefaultHamtBitwidth)
if err != nil {
return nil, err
}
out.State.PendingTxns = em
out.State.PendingTxns = em
return &out, nil
}

View File

@ -14,6 +14,7 @@ import (
"github.com/filecoin-project/lotus/chain/actors/adt"
builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin"
msig6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/multisig"
@ -38,14 +39,14 @@ func make6(store adt.Store, signers []address.Address, threshold uint64, startEp
out.State.StartEpoch = startEpoch
out.State.UnlockDuration = unlockDuration
out.State.InitialBalance = initialBalance
em, err := adt6.StoreEmptyMap(store, builtin6.DefaultHamtBitwidth)
if err != nil {
return nil, err
}
em, err := adt6.StoreEmptyMap(store, builtin6.DefaultHamtBitwidth)
if err != nil {
return nil, err
}
out.State.PendingTxns = em
out.State.PendingTxns = em
return &out, nil
}

View File

@ -14,6 +14,7 @@ import (
"github.com/filecoin-project/lotus/chain/actors/adt"
builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
msig7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/multisig"
@ -38,14 +39,14 @@ func make7(store adt.Store, signers []address.Address, threshold uint64, startEp
out.State.StartEpoch = startEpoch
out.State.UnlockDuration = unlockDuration
out.State.InitialBalance = initialBalance
em, err := adt7.StoreEmptyMap(store, builtin7.DefaultHamtBitwidth)
if err != nil {
return nil, err
}
em, err := adt7.StoreEmptyMap(store, builtin7.DefaultHamtBitwidth)
if err != nil {
return nil, err
}
out.State.PendingTxns = em
out.State.PendingTxns = em
return &out, nil
}

View File

@ -14,6 +14,7 @@ import (
"github.com/filecoin-project/lotus/chain/actors/adt"
builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin"
msig8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/multisig"
@ -38,14 +39,14 @@ func make8(store adt.Store, signers []address.Address, threshold uint64, startEp
out.State.StartEpoch = startEpoch
out.State.UnlockDuration = unlockDuration
out.State.InitialBalance = initialBalance
em, err := adt8.StoreEmptyMap(store, builtin8.DefaultHamtBitwidth)
if err != nil {
return nil, err
}
em, err := adt8.StoreEmptyMap(store, builtin8.DefaultHamtBitwidth)
if err != nil {
return nil, err
}
out.State.PendingTxns = em
out.State.PendingTxns = em
return &out, nil
}

View File

@ -39,9 +39,9 @@ func (m message0) Create(to address.Address, initialAmount abi.TokenAmount) (*ty
func (m message0) Update(paych address.Address, sv *SignedVoucher, secret []byte) (*types.Message, error) {
params, aerr := actors.SerializeParams(&paych0.UpdateChannelStateParams{
Sv: *sv,
Sv: *sv,
Secret: secret,
})
if aerr != nil {

View File

@ -39,9 +39,9 @@ func (m message2) Create(to address.Address, initialAmount abi.TokenAmount) (*ty
func (m message2) Update(paych address.Address, sv *SignedVoucher, secret []byte) (*types.Message, error) {
params, aerr := actors.SerializeParams(&paych2.UpdateChannelStateParams{
Sv: *sv,
Sv: *sv,
Secret: secret,
})
if aerr != nil {

View File

@ -39,9 +39,9 @@ func (m message3) Create(to address.Address, initialAmount abi.TokenAmount) (*ty
func (m message3) Update(paych address.Address, sv *SignedVoucher, secret []byte) (*types.Message, error) {
params, aerr := actors.SerializeParams(&paych3.UpdateChannelStateParams{
Sv: *sv,
Sv: *sv,
Secret: secret,
})
if aerr != nil {

View File

@ -39,9 +39,9 @@ func (m message4) Create(to address.Address, initialAmount abi.TokenAmount) (*ty
func (m message4) Update(paych address.Address, sv *SignedVoucher, secret []byte) (*types.Message, error) {
params, aerr := actors.SerializeParams(&paych4.UpdateChannelStateParams{
Sv: *sv,
Sv: *sv,
Secret: secret,
})
if aerr != nil {

View File

@ -39,9 +39,9 @@ func (m message5) Create(to address.Address, initialAmount abi.TokenAmount) (*ty
func (m message5) Update(paych address.Address, sv *SignedVoucher, secret []byte) (*types.Message, error) {
params, aerr := actors.SerializeParams(&paych5.UpdateChannelStateParams{
Sv: *sv,
Sv: *sv,
Secret: secret,
})
if aerr != nil {

View File

@ -39,9 +39,9 @@ func (m message6) Create(to address.Address, initialAmount abi.TokenAmount) (*ty
func (m message6) Update(paych address.Address, sv *SignedVoucher, secret []byte) (*types.Message, error) {
params, aerr := actors.SerializeParams(&paych6.UpdateChannelStateParams{
Sv: *sv,
Sv: *sv,
Secret: secret,
})
if aerr != nil {

View File

@ -39,9 +39,9 @@ func (m message7) Create(to address.Address, initialAmount abi.TokenAmount) (*ty
func (m message7) Update(paych address.Address, sv *SignedVoucher, secret []byte) (*types.Message, error) {
params, aerr := actors.SerializeParams(&paych7.UpdateChannelStateParams{
Sv: toV7SignedVoucher(*sv),
Sv: toV7SignedVoucher(*sv),
Secret: secret,
})
if aerr != nil {

View File

@ -39,9 +39,9 @@ func (m message8) Create(to address.Address, initialAmount abi.TokenAmount) (*ty
func (m message8) Update(paych address.Address, sv *SignedVoucher, secret []byte) (*types.Message, error) {
params, aerr := actors.SerializeParams(&paych8.UpdateChannelStateParams{
Sv: toV8SignedVoucher(*sv),
Sv: toV8SignedVoucher(*sv),
Secret: secret,
})
if aerr != nil {

View File

@ -31,6 +31,7 @@ import (
builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/actors/builtin"
@ -43,37 +44,121 @@ func init() {
return load0(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version0, "paymentchannel"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load0(store, root)
})
}
builtin.RegisterActorState(builtin2.PaymentChannelActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load2(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version2, "paymentchannel"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load2(store, root)
})
}
builtin.RegisterActorState(builtin3.PaymentChannelActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load3(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version3, "paymentchannel"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load3(store, root)
})
}
builtin.RegisterActorState(builtin4.PaymentChannelActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load4(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version4, "paymentchannel"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load4(store, root)
})
}
builtin.RegisterActorState(builtin5.PaymentChannelActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load5(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version5, "paymentchannel"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load5(store, root)
})
}
builtin.RegisterActorState(builtin6.PaymentChannelActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load6(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version6, "paymentchannel"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load6(store, root)
})
}
builtin.RegisterActorState(builtin7.PaymentChannelActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load7(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version7, "paymentchannel"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load7(store, root)
})
}
builtin.RegisterActorState(builtin8.PaymentChannelActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load8(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version8, "paymentchannel"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load8(store, root)
})
}
}
// Load returns an abstract copy of payment channel state, irregardless of actor version
func Load(store adt.Store, act *types.Actor) (State, error) {
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
if name != "paymentchannel" {
return nil, xerrors.Errorf("actor code is not paymentchannel: %s", name)
}
switch av {
case actors.Version0:
return load0(store, act.Head)
case actors.Version2:
return load2(store, act.Head)
case actors.Version3:
return load3(store, act.Head)
case actors.Version4:
return load4(store, act.Head)
case actors.Version5:
return load5(store, act.Head)
case actors.Version6:
return load6(store, act.Head)
case actors.Version7:
return load7(store, act.Head)
case actors.Version8:
return load8(store, act.Head)
default:
return nil, xerrors.Errorf("unknown actor version: %d", av)
}
}
switch act.Code {
case builtin0.PaymentChannelActorCodeID:
@ -131,11 +216,15 @@ func MakeState(store adt.Store, av actors.Version) (State, error) {
case actors.Version8:
return make8(store)
}
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
if c, ok := actors.GetActorCodeID(av, "paymentchannel"); ok {
return c, nil
}
switch av {
case actors.Version0:

View File

@ -112,3 +112,4 @@ func (ls *laneState0) Redeemed() (big.Int, error) {
func (ls *laneState0) Nonce() (uint64, error) {
return ls.LaneState.Nonce, nil
}

View File

@ -112,3 +112,4 @@ func (ls *laneState2) Redeemed() (big.Int, error) {
func (ls *laneState2) Nonce() (uint64, error) {
return ls.LaneState.Nonce, nil
}

View File

@ -112,3 +112,4 @@ func (ls *laneState3) Redeemed() (big.Int, error) {
func (ls *laneState3) Nonce() (uint64, error) {
return ls.LaneState.Nonce, nil
}

View File

@ -112,3 +112,4 @@ func (ls *laneState4) Redeemed() (big.Int, error) {
func (ls *laneState4) Nonce() (uint64, error) {
return ls.LaneState.Nonce, nil
}

View File

@ -112,3 +112,4 @@ func (ls *laneState5) Redeemed() (big.Int, error) {
func (ls *laneState5) Nonce() (uint64, error) {
return ls.LaneState.Nonce, nil
}

View File

@ -112,3 +112,4 @@ func (ls *laneState6) Redeemed() (big.Int, error) {
func (ls *laneState6) Nonce() (uint64, error) {
return ls.LaneState.Nonce, nil
}

View File

@ -113,6 +113,7 @@ func (ls *laneState7) Nonce() (uint64, error) {
return ls.LaneState.Nonce, nil
}
func toV7SignedVoucher(sv SignedVoucher) paych7.SignedVoucher {
return paych7.SignedVoucher{
ChannelAddr: sv.ChannelAddr,

View File

@ -113,6 +113,7 @@ func (ls *laneState8) Nonce() (uint64, error) {
return ls.LaneState.Nonce, nil
}
func toV8SignedVoucher(sv SignedVoucher) paych8.SignedVoucher {
return paych8.SignedVoucher{
ChannelAddr: sv.ChannelAddr,

View File

@ -30,6 +30,7 @@ import (
builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin"
)
func init() {
@ -38,33 +39,81 @@ func init() {
return load0(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version0, "storagepower"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load0(store, root)
})
}
builtin.RegisterActorState(builtin2.StoragePowerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load2(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version2, "storagepower"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load2(store, root)
})
}
builtin.RegisterActorState(builtin3.StoragePowerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load3(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version3, "storagepower"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load3(store, root)
})
}
builtin.RegisterActorState(builtin4.StoragePowerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load4(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version4, "storagepower"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load4(store, root)
})
}
builtin.RegisterActorState(builtin5.StoragePowerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load5(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version5, "storagepower"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load5(store, root)
})
}
builtin.RegisterActorState(builtin6.StoragePowerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load6(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version6, "storagepower"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load6(store, root)
})
}
builtin.RegisterActorState(builtin7.StoragePowerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load7(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version7, "storagepower"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load7(store, root)
})
}
builtin.RegisterActorState(builtin8.StoragePowerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load8(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version8, "storagepower"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load8(store, root)
})
}
}
var (
@ -73,6 +122,42 @@ var (
)
func Load(store adt.Store, act *types.Actor) (State, error) {
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
if name != "storagepower" {
return nil, xerrors.Errorf("actor code is not storagepower: %s", name)
}
switch av {
case actors.Version0:
return load0(store, act.Head)
case actors.Version2:
return load2(store, act.Head)
case actors.Version3:
return load3(store, act.Head)
case actors.Version4:
return load4(store, act.Head)
case actors.Version5:
return load5(store, act.Head)
case actors.Version6:
return load6(store, act.Head)
case actors.Version7:
return load7(store, act.Head)
case actors.Version8:
return load8(store, act.Head)
default:
return nil, xerrors.Errorf("unknown actor version: %d", av)
}
}
switch act.Code {
case builtin0.StoragePowerActorCodeID:
@ -130,11 +215,15 @@ func MakeState(store adt.Store, av actors.Version) (State, error) {
case actors.Version8:
return make8(store)
}
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
if c, ok := actors.GetActorCodeID(av, "storagepower"); ok {
return c, nil
}
switch av {
case actors.Version0:

View File

@ -11,6 +11,7 @@ import (
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/actors/builtin"
power0 "github.com/filecoin-project/specs-actors/actors/builtin/power"
adt0 "github.com/filecoin-project/specs-actors/actors/util/adt"
)
@ -28,18 +29,19 @@ func load0(store adt.Store, root cid.Cid) (State, error) {
func make0(store adt.Store) (State, error) {
out := state0{store: store}
em, err := adt0.MakeEmptyMap(store).Root()
if err != nil {
return nil, err
}
em, err := adt0.MakeEmptyMap(store).Root()
if err != nil {
return nil, err
}
emm, err := adt0.MakeEmptyMultimap(store).Root()
if err != nil {
return nil, err
}
emm, err := adt0.MakeEmptyMultimap(store).Root()
if err != nil {
return nil, err
}
out.State = *power0.ConstructState(em, emm)
out.State = *power0.ConstructState(em, emm)
return &out, nil
}

View File

@ -11,6 +11,7 @@ import (
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/actors/builtin"
power2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/power"
adt2 "github.com/filecoin-project/specs-actors/v2/actors/util/adt"
)
@ -28,18 +29,19 @@ func load2(store adt.Store, root cid.Cid) (State, error) {
func make2(store adt.Store) (State, error) {
out := state2{store: store}
em, err := adt2.MakeEmptyMap(store).Root()
if err != nil {
return nil, err
}
em, err := adt2.MakeEmptyMap(store).Root()
if err != nil {
return nil, err
}
emm, err := adt2.MakeEmptyMultimap(store).Root()
if err != nil {
return nil, err
}
emm, err := adt2.MakeEmptyMultimap(store).Root()
if err != nil {
return nil, err
}
out.State = *power2.ConstructState(em, emm)
out.State = *power2.ConstructState(em, emm)
return &out, nil
}

View File

@ -11,6 +11,7 @@ import (
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/actors/builtin"
builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin"
power3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/power"
@ -30,13 +31,14 @@ func load3(store adt.Store, root cid.Cid) (State, error) {
func make3(store adt.Store) (State, error) {
out := state3{store: store}
s, err := power3.ConstructState(store)
if err != nil {
return nil, err
}
s, err := power3.ConstructState(store)
if err != nil {
return nil, err
}
out.State = *s
out.State = *s
return &out, nil
}

View File

@ -11,6 +11,7 @@ import (
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/actors/builtin"
builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin"
power4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/power"
@ -30,13 +31,14 @@ func load4(store adt.Store, root cid.Cid) (State, error) {
func make4(store adt.Store) (State, error) {
out := state4{store: store}
s, err := power4.ConstructState(store)
if err != nil {
return nil, err
}
s, err := power4.ConstructState(store)
if err != nil {
return nil, err
}
out.State = *s
out.State = *s
return &out, nil
}

View File

@ -11,6 +11,7 @@ import (
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/actors/builtin"
builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin"
power5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/power"
@ -30,13 +31,14 @@ func load5(store adt.Store, root cid.Cid) (State, error) {
func make5(store adt.Store) (State, error) {
out := state5{store: store}
s, err := power5.ConstructState(store)
if err != nil {
return nil, err
}
s, err := power5.ConstructState(store)
if err != nil {
return nil, err
}
out.State = *s
out.State = *s
return &out, nil
}

View File

@ -11,6 +11,7 @@ import (
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/actors/builtin"
builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin"
power6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/power"
@ -30,13 +31,14 @@ func load6(store adt.Store, root cid.Cid) (State, error) {
func make6(store adt.Store) (State, error) {
out := state6{store: store}
s, err := power6.ConstructState(store)
if err != nil {
return nil, err
}
s, err := power6.ConstructState(store)
if err != nil {
return nil, err
}
out.State = *s
out.State = *s
return &out, nil
}

View File

@ -11,6 +11,7 @@ import (
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/actors/builtin"
builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
power7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/power"
@ -30,13 +31,14 @@ func load7(store adt.Store, root cid.Cid) (State, error) {
func make7(store adt.Store) (State, error) {
out := state7{store: store}
s, err := power7.ConstructState(store)
if err != nil {
return nil, err
}
s, err := power7.ConstructState(store)
if err != nil {
return nil, err
}
out.State = *s
out.State = *s
return &out, nil
}

View File

@ -11,6 +11,7 @@ import (
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/actors/builtin"
builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin"
power8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/power"
@ -30,13 +31,14 @@ func load8(store adt.Store, root cid.Cid) (State, error) {
func make8(store adt.Store) (State, error) {
out := state8{store: store}
s, err := power8.ConstructState(store)
if err != nil {
return nil, err
}
s, err := power8.ConstructState(store)
if err != nil {
return nil, err
}
out.State = *s
out.State = *s
return &out, nil
}

View File

@ -2,9 +2,9 @@ package reward
import (
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/lotus/chain/actors"
reward0 "github.com/filecoin-project/specs-actors/actors/builtin/reward"
"github.com/ipfs/go-cid"
"github.com/filecoin-project/lotus/chain/actors"
"golang.org/x/xerrors"
"github.com/filecoin-project/go-state-types/cbor"
@ -25,6 +25,7 @@ import (
builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/actors/builtin"
"github.com/filecoin-project/lotus/chain/types"
@ -36,33 +37,81 @@ func init() {
return load0(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version0, "reward"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load0(store, root)
})
}
builtin.RegisterActorState(builtin2.RewardActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load2(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version2, "reward"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load2(store, root)
})
}
builtin.RegisterActorState(builtin3.RewardActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load3(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version3, "reward"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load3(store, root)
})
}
builtin.RegisterActorState(builtin4.RewardActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load4(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version4, "reward"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load4(store, root)
})
}
builtin.RegisterActorState(builtin5.RewardActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load5(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version5, "reward"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load5(store, root)
})
}
builtin.RegisterActorState(builtin6.RewardActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load6(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version6, "reward"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load6(store, root)
})
}
builtin.RegisterActorState(builtin7.RewardActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load7(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version7, "reward"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load7(store, root)
})
}
builtin.RegisterActorState(builtin8.RewardActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load8(store, root)
})
if c, ok := actors.GetActorCodeID(actors.Version8, "reward"); ok {
builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load8(store, root)
})
}
}
var (
@ -71,6 +120,42 @@ var (
)
func Load(store adt.Store, act *types.Actor) (State, error) {
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
if name != "reward" {
return nil, xerrors.Errorf("actor code is not reward: %s", name)
}
switch av {
case actors.Version0:
return load0(store, act.Head)
case actors.Version2:
return load2(store, act.Head)
case actors.Version3:
return load3(store, act.Head)
case actors.Version4:
return load4(store, act.Head)
case actors.Version5:
return load5(store, act.Head)
case actors.Version6:
return load6(store, act.Head)
case actors.Version7:
return load7(store, act.Head)
case actors.Version8:
return load8(store, act.Head)
default:
return nil, xerrors.Errorf("unknown actor version: %d", av)
}
}
switch act.Code {
case builtin0.RewardActorCodeID:
@ -128,11 +213,15 @@ func MakeState(store adt.Store, av actors.Version, currRealizedPower abi.Storage
case actors.Version8:
return make8(store, currRealizedPower)
}
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
if c, ok := actors.GetActorCodeID(av, "reward"); ok {
return c, nil
}
switch av {
case actors.Version0:

View File

@ -40,7 +40,7 @@ func (s *state2) ThisEpochReward() (abi.TokenAmount, error) {
func (s *state2) ThisEpochRewardSmoothed() (builtin.FilterEstimate, error) {
return builtin.FilterEstimate{
return builtin.FilterEstimate{
PositionEstimate: s.State.ThisEpochRewardSmoothed.PositionEstimate,
VelocityEstimate: s.State.ThisEpochRewardSmoothed.VelocityEstimate,
}, nil

View File

@ -40,7 +40,7 @@ func (s *state3) ThisEpochReward() (abi.TokenAmount, error) {
func (s *state3) ThisEpochRewardSmoothed() (builtin.FilterEstimate, error) {
return builtin.FilterEstimate{
return builtin.FilterEstimate{
PositionEstimate: s.State.ThisEpochRewardSmoothed.PositionEstimate,
VelocityEstimate: s.State.ThisEpochRewardSmoothed.VelocityEstimate,
}, nil

View File

@ -40,7 +40,7 @@ func (s *state4) ThisEpochReward() (abi.TokenAmount, error) {
func (s *state4) ThisEpochRewardSmoothed() (builtin.FilterEstimate, error) {
return builtin.FilterEstimate{
return builtin.FilterEstimate{
PositionEstimate: s.State.ThisEpochRewardSmoothed.PositionEstimate,
VelocityEstimate: s.State.ThisEpochRewardSmoothed.VelocityEstimate,
}, nil

View File

@ -40,7 +40,7 @@ func (s *state5) ThisEpochReward() (abi.TokenAmount, error) {
func (s *state5) ThisEpochRewardSmoothed() (builtin.FilterEstimate, error) {
return builtin.FilterEstimate{
return builtin.FilterEstimate{
PositionEstimate: s.State.ThisEpochRewardSmoothed.PositionEstimate,
VelocityEstimate: s.State.ThisEpochRewardSmoothed.VelocityEstimate,
}, nil

View File

@ -40,7 +40,7 @@ func (s *state6) ThisEpochReward() (abi.TokenAmount, error) {
func (s *state6) ThisEpochRewardSmoothed() (builtin.FilterEstimate, error) {
return builtin.FilterEstimate{
return builtin.FilterEstimate{
PositionEstimate: s.State.ThisEpochRewardSmoothed.PositionEstimate,
VelocityEstimate: s.State.ThisEpochRewardSmoothed.VelocityEstimate,
}, nil

View File

@ -40,7 +40,7 @@ func (s *state7) ThisEpochReward() (abi.TokenAmount, error) {
func (s *state7) ThisEpochRewardSmoothed() (builtin.FilterEstimate, error) {
return builtin.FilterEstimate{
return builtin.FilterEstimate{
PositionEstimate: s.State.ThisEpochRewardSmoothed.PositionEstimate,
VelocityEstimate: s.State.ThisEpochRewardSmoothed.VelocityEstimate,
}, nil

View File

@ -40,7 +40,7 @@ func (s *state8) ThisEpochReward() (abi.TokenAmount, error) {
func (s *state8) ThisEpochRewardSmoothed() (builtin.FilterEstimate, error) {
return builtin.FilterEstimate{
return builtin.FilterEstimate{
PositionEstimate: s.State.ThisEpochRewardSmoothed.PositionEstimate,
VelocityEstimate: s.State.ThisEpochRewardSmoothed.VelocityEstimate,
}, nil

View File

@ -1,10 +1,11 @@
package system
import (
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/ipfs/go-cid"
"github.com/filecoin-project/lotus/chain/actors"
"golang.org/x/xerrors"
"github.com/ipfs/go-cid"
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
@ -21,6 +22,7 @@ import (
builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin"
)
var (
@ -54,11 +56,15 @@ func MakeState(store adt.Store, av actors.Version) (State, error) {
case actors.Version8:
return make8(store)
}
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
if c, ok := actors.GetActorCodeID(av, "system"); ok {
return c, nil
}
switch av {
case actors.Version0:

View File

@ -32,4 +32,4 @@ type state0 struct {
func (s *state0) GetState() interface{} {
return &s.State
}
}

View File

@ -32,4 +32,4 @@ type state2 struct {
func (s *state2) GetState() interface{} {
return &s.State
}
}

Some files were not shown because too many files have changed in this diff Show More