diff --git a/chain/actors/builtin/account/account.go b/chain/actors/builtin/account/account.go index 9fb92d88d..d530ed6c5 100644 --- a/chain/actors/builtin/account/account.go +++ b/chain/actors/builtin/account/account.go @@ -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: diff --git a/chain/actors/builtin/account/v0.go b/chain/actors/builtin/account/v0.go index bdfca2fd7..2e14abbe0 100644 --- a/chain/actors/builtin/account/v0.go +++ b/chain/actors/builtin/account/v0.go @@ -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 -} +} \ No newline at end of file diff --git a/chain/actors/builtin/account/v2.go b/chain/actors/builtin/account/v2.go index 66618e06a..0f570587f 100644 --- a/chain/actors/builtin/account/v2.go +++ b/chain/actors/builtin/account/v2.go @@ -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 -} +} \ No newline at end of file diff --git a/chain/actors/builtin/account/v3.go b/chain/actors/builtin/account/v3.go index dbe100a4f..7a293fb62 100644 --- a/chain/actors/builtin/account/v3.go +++ b/chain/actors/builtin/account/v3.go @@ -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 -} +} \ No newline at end of file diff --git a/chain/actors/builtin/account/v4.go b/chain/actors/builtin/account/v4.go index 53f71dcc5..1c71eb536 100644 --- a/chain/actors/builtin/account/v4.go +++ b/chain/actors/builtin/account/v4.go @@ -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 -} +} \ No newline at end of file diff --git a/chain/actors/builtin/account/v5.go b/chain/actors/builtin/account/v5.go index 538f56987..5ebdee61c 100644 --- a/chain/actors/builtin/account/v5.go +++ b/chain/actors/builtin/account/v5.go @@ -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 -} +} \ No newline at end of file diff --git a/chain/actors/builtin/account/v6.go b/chain/actors/builtin/account/v6.go index a0d157ae5..895eeb9fe 100644 --- a/chain/actors/builtin/account/v6.go +++ b/chain/actors/builtin/account/v6.go @@ -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 -} +} \ No newline at end of file diff --git a/chain/actors/builtin/account/v7.go b/chain/actors/builtin/account/v7.go index 883776cf8..e4e58b667 100644 --- a/chain/actors/builtin/account/v7.go +++ b/chain/actors/builtin/account/v7.go @@ -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 -} +} \ No newline at end of file diff --git a/chain/actors/builtin/account/v8.go b/chain/actors/builtin/account/v8.go index 5404b3262..4d2a24157 100644 --- a/chain/actors/builtin/account/v8.go +++ b/chain/actors/builtin/account/v8.go @@ -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 -} +} \ No newline at end of file diff --git a/chain/actors/builtin/builtin.go b/chain/actors/builtin/builtin.go index 079918c50..467f63651 100644 --- a/chain/actors/builtin/builtin.go +++ b/chain/actors/builtin/builtin.go @@ -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 "" } } 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 } diff --git a/chain/actors/builtin/cron/cron.go b/chain/actors/builtin/cron/cron.go index e0a08408b..c4d194176 100644 --- a/chain/actors/builtin/cron/cron.go +++ b/chain/actors/builtin/cron/cron.go @@ -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{} } diff --git a/chain/actors/builtin/cron/v0.go b/chain/actors/builtin/cron/v0.go index 6147b858c..7b6b26e05 100644 --- a/chain/actors/builtin/cron/v0.go +++ b/chain/actors/builtin/cron/v0.go @@ -32,4 +32,4 @@ type state0 struct { func (s *state0) GetState() interface{} { return &s.State -} +} \ No newline at end of file diff --git a/chain/actors/builtin/cron/v2.go b/chain/actors/builtin/cron/v2.go index 51ca179d9..032435b96 100644 --- a/chain/actors/builtin/cron/v2.go +++ b/chain/actors/builtin/cron/v2.go @@ -32,4 +32,4 @@ type state2 struct { func (s *state2) GetState() interface{} { return &s.State -} +} \ No newline at end of file diff --git a/chain/actors/builtin/cron/v3.go b/chain/actors/builtin/cron/v3.go index ff74d511d..62c670b68 100644 --- a/chain/actors/builtin/cron/v3.go +++ b/chain/actors/builtin/cron/v3.go @@ -32,4 +32,4 @@ type state3 struct { func (s *state3) GetState() interface{} { return &s.State -} +} \ No newline at end of file diff --git a/chain/actors/builtin/cron/v4.go b/chain/actors/builtin/cron/v4.go index 1cff8cc28..b13ea78ac 100644 --- a/chain/actors/builtin/cron/v4.go +++ b/chain/actors/builtin/cron/v4.go @@ -32,4 +32,4 @@ type state4 struct { func (s *state4) GetState() interface{} { return &s.State -} +} \ No newline at end of file diff --git a/chain/actors/builtin/cron/v5.go b/chain/actors/builtin/cron/v5.go index 2bb00dc21..a60269d83 100644 --- a/chain/actors/builtin/cron/v5.go +++ b/chain/actors/builtin/cron/v5.go @@ -32,4 +32,4 @@ type state5 struct { func (s *state5) GetState() interface{} { return &s.State -} +} \ No newline at end of file diff --git a/chain/actors/builtin/cron/v6.go b/chain/actors/builtin/cron/v6.go index 8bbadd79f..be9ee00c9 100644 --- a/chain/actors/builtin/cron/v6.go +++ b/chain/actors/builtin/cron/v6.go @@ -32,4 +32,4 @@ type state6 struct { func (s *state6) GetState() interface{} { return &s.State -} +} \ No newline at end of file diff --git a/chain/actors/builtin/cron/v7.go b/chain/actors/builtin/cron/v7.go index e5538c89f..67a46f3ff 100644 --- a/chain/actors/builtin/cron/v7.go +++ b/chain/actors/builtin/cron/v7.go @@ -32,4 +32,4 @@ type state7 struct { func (s *state7) GetState() interface{} { return &s.State -} +} \ No newline at end of file diff --git a/chain/actors/builtin/cron/v8.go b/chain/actors/builtin/cron/v8.go index 97c0aa980..2eec8b47a 100644 --- a/chain/actors/builtin/cron/v8.go +++ b/chain/actors/builtin/cron/v8.go @@ -32,4 +32,4 @@ type state8 struct { func (s *state8) GetState() interface{} { return &s.State -} +} \ No newline at end of file diff --git a/chain/actors/builtin/init/init.go b/chain/actors/builtin/init/init.go index cdae9b503..3174b3675 100644 --- a/chain/actors/builtin/init/init.go +++ b/chain/actors/builtin/init/init.go @@ -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: diff --git a/chain/actors/builtin/init/v0.go b/chain/actors/builtin/init/v0.go index ddd2dab94..a5edff01a 100644 --- a/chain/actors/builtin/init/v0.go +++ b/chain/actors/builtin/init/v0.go @@ -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 -} +} \ No newline at end of file diff --git a/chain/actors/builtin/init/v2.go b/chain/actors/builtin/init/v2.go index 72e2d56a5..5bbd778f9 100644 --- a/chain/actors/builtin/init/v2.go +++ b/chain/actors/builtin/init/v2.go @@ -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 -} +} \ No newline at end of file diff --git a/chain/actors/builtin/init/v3.go b/chain/actors/builtin/init/v3.go index 4609c94a3..c1141ba88 100644 --- a/chain/actors/builtin/init/v3.go +++ b/chain/actors/builtin/init/v3.go @@ -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 -} +} \ No newline at end of file diff --git a/chain/actors/builtin/init/v4.go b/chain/actors/builtin/init/v4.go index dc56d1f19..17bf03830 100644 --- a/chain/actors/builtin/init/v4.go +++ b/chain/actors/builtin/init/v4.go @@ -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 -} +} \ No newline at end of file diff --git a/chain/actors/builtin/init/v5.go b/chain/actors/builtin/init/v5.go index 107366de5..3d61513c5 100644 --- a/chain/actors/builtin/init/v5.go +++ b/chain/actors/builtin/init/v5.go @@ -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 -} +} \ No newline at end of file diff --git a/chain/actors/builtin/init/v6.go b/chain/actors/builtin/init/v6.go index a5bd9edfb..a91c8fda0 100644 --- a/chain/actors/builtin/init/v6.go +++ b/chain/actors/builtin/init/v6.go @@ -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 -} +} \ No newline at end of file diff --git a/chain/actors/builtin/init/v7.go b/chain/actors/builtin/init/v7.go index 341aa52cd..4cba8f695 100644 --- a/chain/actors/builtin/init/v7.go +++ b/chain/actors/builtin/init/v7.go @@ -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 -} +} \ No newline at end of file diff --git a/chain/actors/builtin/init/v8.go b/chain/actors/builtin/init/v8.go index 1fc2859a0..493aae4cf 100644 --- a/chain/actors/builtin/init/v8.go +++ b/chain/actors/builtin/init/v8.go @@ -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 -} +} \ No newline at end of file diff --git a/chain/actors/builtin/market/market.go b/chain/actors/builtin/market/market.go index 00524f0cb..d17cd6290 100644 --- a/chain/actors/builtin/market/market.go +++ b/chain/actors/builtin/market/market.go @@ -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) } diff --git a/chain/actors/builtin/market/v0.go b/chain/actors/builtin/market/v0.go index f5a60b229..e883f9b8f 100644 --- a/chain/actors/builtin/market/v0.go +++ b/chain/actors/builtin/market/v0.go @@ -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 } diff --git a/chain/actors/builtin/market/v2.go b/chain/actors/builtin/market/v2.go index 3c6914d0c..731f48d50 100644 --- a/chain/actors/builtin/market/v2.go +++ b/chain/actors/builtin/market/v2.go @@ -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 } diff --git a/chain/actors/builtin/market/v3.go b/chain/actors/builtin/market/v3.go index 2409bb05b..c47b0ff52 100644 --- a/chain/actors/builtin/market/v3.go +++ b/chain/actors/builtin/market/v3.go @@ -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 } diff --git a/chain/actors/builtin/market/v4.go b/chain/actors/builtin/market/v4.go index 4e9011d10..4904e74a9 100644 --- a/chain/actors/builtin/market/v4.go +++ b/chain/actors/builtin/market/v4.go @@ -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 } diff --git a/chain/actors/builtin/market/v5.go b/chain/actors/builtin/market/v5.go index 139a32247..b1199c188 100644 --- a/chain/actors/builtin/market/v5.go +++ b/chain/actors/builtin/market/v5.go @@ -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 } diff --git a/chain/actors/builtin/market/v6.go b/chain/actors/builtin/market/v6.go index 8230f3cf1..b50b8cb4d 100644 --- a/chain/actors/builtin/market/v6.go +++ b/chain/actors/builtin/market/v6.go @@ -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 } diff --git a/chain/actors/builtin/market/v7.go b/chain/actors/builtin/market/v7.go index 553913146..057e8df7f 100644 --- a/chain/actors/builtin/market/v7.go +++ b/chain/actors/builtin/market/v7.go @@ -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 } diff --git a/chain/actors/builtin/market/v8.go b/chain/actors/builtin/market/v8.go index d2e6f9189..284536dbd 100644 --- a/chain/actors/builtin/market/v8.go +++ b/chain/actors/builtin/market/v8.go @@ -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 } diff --git a/chain/actors/builtin/miner/miner.go b/chain/actors/builtin/miner/miner.go index 1e0c46183..a3e367aeb 100644 --- a/chain/actors/builtin/miner/miner.go +++ b/chain/actors/builtin/miner/miner.go @@ -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) diff --git a/chain/actors/builtin/miner/v0.go b/chain/actors/builtin/miner/v0.go index 8bde8bf73..9f59188f6 100644 --- a/chain/actors/builtin/miner/v0.go +++ b/chain/actors/builtin/miner/v0.go @@ -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 } diff --git a/chain/actors/builtin/miner/v2.go b/chain/actors/builtin/miner/v2.go index bbfdd403e..d04db9cd6 100644 --- a/chain/actors/builtin/miner/v2.go +++ b/chain/actors/builtin/miner/v2.go @@ -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 } diff --git a/chain/actors/builtin/miner/v3.go b/chain/actors/builtin/miner/v3.go index 68505918a..7b4ec4e24 100644 --- a/chain/actors/builtin/miner/v3.go +++ b/chain/actors/builtin/miner/v3.go @@ -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 } diff --git a/chain/actors/builtin/miner/v4.go b/chain/actors/builtin/miner/v4.go index 5c40d4189..f4042bdea 100644 --- a/chain/actors/builtin/miner/v4.go +++ b/chain/actors/builtin/miner/v4.go @@ -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 } diff --git a/chain/actors/builtin/miner/v5.go b/chain/actors/builtin/miner/v5.go index f717934f4..847bf2419 100644 --- a/chain/actors/builtin/miner/v5.go +++ b/chain/actors/builtin/miner/v5.go @@ -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 } diff --git a/chain/actors/builtin/miner/v6.go b/chain/actors/builtin/miner/v6.go index 7a9dfb0df..6af030cf7 100644 --- a/chain/actors/builtin/miner/v6.go +++ b/chain/actors/builtin/miner/v6.go @@ -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 } diff --git a/chain/actors/builtin/miner/v7.go b/chain/actors/builtin/miner/v7.go index e1b2520e4..0e56f215e 100644 --- a/chain/actors/builtin/miner/v7.go +++ b/chain/actors/builtin/miner/v7.go @@ -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 } diff --git a/chain/actors/builtin/miner/v8.go b/chain/actors/builtin/miner/v8.go index 82b8d0e20..3752af257 100644 --- a/chain/actors/builtin/miner/v8.go +++ b/chain/actors/builtin/miner/v8.go @@ -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 } diff --git a/chain/actors/builtin/multisig/message0.go b/chain/actors/builtin/multisig/message0.go index dc43a9d5d..2849d4bb9 100644 --- a/chain/actors/builtin/multisig/message0.go +++ b/chain/actors/builtin/multisig/message0.go @@ -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 } + diff --git a/chain/actors/builtin/multisig/message2.go b/chain/actors/builtin/multisig/message2.go index da2700d06..8715fa6c0 100644 --- a/chain/actors/builtin/multisig/message2.go +++ b/chain/actors/builtin/multisig/message2.go @@ -69,3 +69,5 @@ func (m message2) Create( Value: initialAmount, }, nil } + + diff --git a/chain/actors/builtin/multisig/message3.go b/chain/actors/builtin/multisig/message3.go index f5f6d8cdf..b58591a96 100644 --- a/chain/actors/builtin/multisig/message3.go +++ b/chain/actors/builtin/multisig/message3.go @@ -69,3 +69,5 @@ func (m message3) Create( Value: initialAmount, }, nil } + + diff --git a/chain/actors/builtin/multisig/message4.go b/chain/actors/builtin/multisig/message4.go index 90885aa07..601657985 100644 --- a/chain/actors/builtin/multisig/message4.go +++ b/chain/actors/builtin/multisig/message4.go @@ -69,3 +69,5 @@ func (m message4) Create( Value: initialAmount, }, nil } + + diff --git a/chain/actors/builtin/multisig/message5.go b/chain/actors/builtin/multisig/message5.go index 9a8110f2c..ec74f4c5a 100644 --- a/chain/actors/builtin/multisig/message5.go +++ b/chain/actors/builtin/multisig/message5.go @@ -69,3 +69,5 @@ func (m message5) Create( Value: initialAmount, }, nil } + + diff --git a/chain/actors/builtin/multisig/message6.go b/chain/actors/builtin/multisig/message6.go index b2b95245e..259fe71ee 100644 --- a/chain/actors/builtin/multisig/message6.go +++ b/chain/actors/builtin/multisig/message6.go @@ -69,3 +69,5 @@ func (m message6) Create( Value: initialAmount, }, nil } + + diff --git a/chain/actors/builtin/multisig/message7.go b/chain/actors/builtin/multisig/message7.go index e7fb83e9b..1d6bd2f18 100644 --- a/chain/actors/builtin/multisig/message7.go +++ b/chain/actors/builtin/multisig/message7.go @@ -69,3 +69,5 @@ func (m message7) Create( Value: initialAmount, }, nil } + + diff --git a/chain/actors/builtin/multisig/message8.go b/chain/actors/builtin/multisig/message8.go index 9852af105..1a97eb074 100644 --- a/chain/actors/builtin/multisig/message8.go +++ b/chain/actors/builtin/multisig/message8.go @@ -69,3 +69,5 @@ func (m message8) Create( Value: initialAmount, }, nil } + + diff --git a/chain/actors/builtin/multisig/multisig.go b/chain/actors/builtin/multisig/multisig.go index 0ccce071c..9fd29a6da 100644 --- a/chain/actors/builtin/multisig/multisig.go +++ b/chain/actors/builtin/multisig/multisig.go @@ -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: diff --git a/chain/actors/builtin/multisig/v0.go b/chain/actors/builtin/multisig/v0.go index 973ac9209..26b4f7d28 100644 --- a/chain/actors/builtin/multisig/v0.go +++ b/chain/actors/builtin/multisig/v0.go @@ -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 } diff --git a/chain/actors/builtin/multisig/v2.go b/chain/actors/builtin/multisig/v2.go index 5b830e695..44e83643a 100644 --- a/chain/actors/builtin/multisig/v2.go +++ b/chain/actors/builtin/multisig/v2.go @@ -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 } diff --git a/chain/actors/builtin/multisig/v3.go b/chain/actors/builtin/multisig/v3.go index c4a2791b7..d721744fe 100644 --- a/chain/actors/builtin/multisig/v3.go +++ b/chain/actors/builtin/multisig/v3.go @@ -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 } diff --git a/chain/actors/builtin/multisig/v4.go b/chain/actors/builtin/multisig/v4.go index a35a890f8..9473daa6e 100644 --- a/chain/actors/builtin/multisig/v4.go +++ b/chain/actors/builtin/multisig/v4.go @@ -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 } diff --git a/chain/actors/builtin/multisig/v5.go b/chain/actors/builtin/multisig/v5.go index 4ad9aea94..08ef1dcb5 100644 --- a/chain/actors/builtin/multisig/v5.go +++ b/chain/actors/builtin/multisig/v5.go @@ -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 } diff --git a/chain/actors/builtin/multisig/v6.go b/chain/actors/builtin/multisig/v6.go index fa16494f8..cff943701 100644 --- a/chain/actors/builtin/multisig/v6.go +++ b/chain/actors/builtin/multisig/v6.go @@ -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 } diff --git a/chain/actors/builtin/multisig/v7.go b/chain/actors/builtin/multisig/v7.go index bbe41f3db..ee1d6e131 100644 --- a/chain/actors/builtin/multisig/v7.go +++ b/chain/actors/builtin/multisig/v7.go @@ -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 } diff --git a/chain/actors/builtin/multisig/v8.go b/chain/actors/builtin/multisig/v8.go index 9ac8224da..d768a0385 100644 --- a/chain/actors/builtin/multisig/v8.go +++ b/chain/actors/builtin/multisig/v8.go @@ -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 } diff --git a/chain/actors/builtin/paych/message0.go b/chain/actors/builtin/paych/message0.go index 7cba977e3..95e0120d9 100644 --- a/chain/actors/builtin/paych/message0.go +++ b/chain/actors/builtin/paych/message0.go @@ -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 { diff --git a/chain/actors/builtin/paych/message2.go b/chain/actors/builtin/paych/message2.go index 60c7fe16e..f1b7dc8eb 100644 --- a/chain/actors/builtin/paych/message2.go +++ b/chain/actors/builtin/paych/message2.go @@ -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 { diff --git a/chain/actors/builtin/paych/message3.go b/chain/actors/builtin/paych/message3.go index 04fb35b57..ba82939d1 100644 --- a/chain/actors/builtin/paych/message3.go +++ b/chain/actors/builtin/paych/message3.go @@ -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 { diff --git a/chain/actors/builtin/paych/message4.go b/chain/actors/builtin/paych/message4.go index 9f5e000d9..e285edd4b 100644 --- a/chain/actors/builtin/paych/message4.go +++ b/chain/actors/builtin/paych/message4.go @@ -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 { diff --git a/chain/actors/builtin/paych/message5.go b/chain/actors/builtin/paych/message5.go index 71e6b6799..00e3b1dcd 100644 --- a/chain/actors/builtin/paych/message5.go +++ b/chain/actors/builtin/paych/message5.go @@ -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 { diff --git a/chain/actors/builtin/paych/message6.go b/chain/actors/builtin/paych/message6.go index 7f80bc4a6..05e690449 100644 --- a/chain/actors/builtin/paych/message6.go +++ b/chain/actors/builtin/paych/message6.go @@ -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 { diff --git a/chain/actors/builtin/paych/message7.go b/chain/actors/builtin/paych/message7.go index e3ee0d77b..3930c8074 100644 --- a/chain/actors/builtin/paych/message7.go +++ b/chain/actors/builtin/paych/message7.go @@ -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 { diff --git a/chain/actors/builtin/paych/message8.go b/chain/actors/builtin/paych/message8.go index f49f457e8..620c6850b 100644 --- a/chain/actors/builtin/paych/message8.go +++ b/chain/actors/builtin/paych/message8.go @@ -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 { diff --git a/chain/actors/builtin/paych/paych.go b/chain/actors/builtin/paych/paych.go index 2e0c932cd..e9a5ebfba 100644 --- a/chain/actors/builtin/paych/paych.go +++ b/chain/actors/builtin/paych/paych.go @@ -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: diff --git a/chain/actors/builtin/paych/v0.go b/chain/actors/builtin/paych/v0.go index e9bc30e3d..4da111619 100644 --- a/chain/actors/builtin/paych/v0.go +++ b/chain/actors/builtin/paych/v0.go @@ -112,3 +112,4 @@ func (ls *laneState0) Redeemed() (big.Int, error) { func (ls *laneState0) Nonce() (uint64, error) { return ls.LaneState.Nonce, nil } + diff --git a/chain/actors/builtin/paych/v2.go b/chain/actors/builtin/paych/v2.go index 400305e2f..a38563cbf 100644 --- a/chain/actors/builtin/paych/v2.go +++ b/chain/actors/builtin/paych/v2.go @@ -112,3 +112,4 @@ func (ls *laneState2) Redeemed() (big.Int, error) { func (ls *laneState2) Nonce() (uint64, error) { return ls.LaneState.Nonce, nil } + diff --git a/chain/actors/builtin/paych/v3.go b/chain/actors/builtin/paych/v3.go index 1d7c2f94b..41fccf77b 100644 --- a/chain/actors/builtin/paych/v3.go +++ b/chain/actors/builtin/paych/v3.go @@ -112,3 +112,4 @@ func (ls *laneState3) Redeemed() (big.Int, error) { func (ls *laneState3) Nonce() (uint64, error) { return ls.LaneState.Nonce, nil } + diff --git a/chain/actors/builtin/paych/v4.go b/chain/actors/builtin/paych/v4.go index b7d1e52a5..b98582fc9 100644 --- a/chain/actors/builtin/paych/v4.go +++ b/chain/actors/builtin/paych/v4.go @@ -112,3 +112,4 @@ func (ls *laneState4) Redeemed() (big.Int, error) { func (ls *laneState4) Nonce() (uint64, error) { return ls.LaneState.Nonce, nil } + diff --git a/chain/actors/builtin/paych/v5.go b/chain/actors/builtin/paych/v5.go index b331a1500..51ce6966b 100644 --- a/chain/actors/builtin/paych/v5.go +++ b/chain/actors/builtin/paych/v5.go @@ -112,3 +112,4 @@ func (ls *laneState5) Redeemed() (big.Int, error) { func (ls *laneState5) Nonce() (uint64, error) { return ls.LaneState.Nonce, nil } + diff --git a/chain/actors/builtin/paych/v6.go b/chain/actors/builtin/paych/v6.go index 0d60b1f03..51d27df42 100644 --- a/chain/actors/builtin/paych/v6.go +++ b/chain/actors/builtin/paych/v6.go @@ -112,3 +112,4 @@ func (ls *laneState6) Redeemed() (big.Int, error) { func (ls *laneState6) Nonce() (uint64, error) { return ls.LaneState.Nonce, nil } + diff --git a/chain/actors/builtin/paych/v7.go b/chain/actors/builtin/paych/v7.go index 19c801c82..57b78fc02 100644 --- a/chain/actors/builtin/paych/v7.go +++ b/chain/actors/builtin/paych/v7.go @@ -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, diff --git a/chain/actors/builtin/paych/v8.go b/chain/actors/builtin/paych/v8.go index 06e724e4c..752a160e0 100644 --- a/chain/actors/builtin/paych/v8.go +++ b/chain/actors/builtin/paych/v8.go @@ -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, diff --git a/chain/actors/builtin/power/power.go b/chain/actors/builtin/power/power.go index ffc5cd702..b995d9086 100644 --- a/chain/actors/builtin/power/power.go +++ b/chain/actors/builtin/power/power.go @@ -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: diff --git a/chain/actors/builtin/power/v0.go b/chain/actors/builtin/power/v0.go index 465d16c5c..dd62f48ef 100644 --- a/chain/actors/builtin/power/v0.go +++ b/chain/actors/builtin/power/v0.go @@ -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 } diff --git a/chain/actors/builtin/power/v2.go b/chain/actors/builtin/power/v2.go index 606534cef..54674c5db 100644 --- a/chain/actors/builtin/power/v2.go +++ b/chain/actors/builtin/power/v2.go @@ -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 } diff --git a/chain/actors/builtin/power/v3.go b/chain/actors/builtin/power/v3.go index 3dec3c63e..ecc5efa82 100644 --- a/chain/actors/builtin/power/v3.go +++ b/chain/actors/builtin/power/v3.go @@ -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 } diff --git a/chain/actors/builtin/power/v4.go b/chain/actors/builtin/power/v4.go index b73eedf5a..ac5f87515 100644 --- a/chain/actors/builtin/power/v4.go +++ b/chain/actors/builtin/power/v4.go @@ -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 } diff --git a/chain/actors/builtin/power/v5.go b/chain/actors/builtin/power/v5.go index 84b23a577..408af81e5 100644 --- a/chain/actors/builtin/power/v5.go +++ b/chain/actors/builtin/power/v5.go @@ -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 } diff --git a/chain/actors/builtin/power/v6.go b/chain/actors/builtin/power/v6.go index 4273c2c73..73ef6b69d 100644 --- a/chain/actors/builtin/power/v6.go +++ b/chain/actors/builtin/power/v6.go @@ -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 } diff --git a/chain/actors/builtin/power/v7.go b/chain/actors/builtin/power/v7.go index af1761cb2..128457248 100644 --- a/chain/actors/builtin/power/v7.go +++ b/chain/actors/builtin/power/v7.go @@ -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 } diff --git a/chain/actors/builtin/power/v8.go b/chain/actors/builtin/power/v8.go index 622dd96ba..17b7d52f7 100644 --- a/chain/actors/builtin/power/v8.go +++ b/chain/actors/builtin/power/v8.go @@ -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 } diff --git a/chain/actors/builtin/reward/reward.go b/chain/actors/builtin/reward/reward.go index a83a3362e..27cd28e74 100644 --- a/chain/actors/builtin/reward/reward.go +++ b/chain/actors/builtin/reward/reward.go @@ -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: diff --git a/chain/actors/builtin/reward/v2.go b/chain/actors/builtin/reward/v2.go index 08e9a7bc3..fc475782d 100644 --- a/chain/actors/builtin/reward/v2.go +++ b/chain/actors/builtin/reward/v2.go @@ -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 diff --git a/chain/actors/builtin/reward/v3.go b/chain/actors/builtin/reward/v3.go index fd9fa56e2..0029f1e9b 100644 --- a/chain/actors/builtin/reward/v3.go +++ b/chain/actors/builtin/reward/v3.go @@ -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 diff --git a/chain/actors/builtin/reward/v4.go b/chain/actors/builtin/reward/v4.go index 310ca04e8..721cafc3f 100644 --- a/chain/actors/builtin/reward/v4.go +++ b/chain/actors/builtin/reward/v4.go @@ -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 diff --git a/chain/actors/builtin/reward/v5.go b/chain/actors/builtin/reward/v5.go index 7200f7d11..cb25b1fb2 100644 --- a/chain/actors/builtin/reward/v5.go +++ b/chain/actors/builtin/reward/v5.go @@ -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 diff --git a/chain/actors/builtin/reward/v6.go b/chain/actors/builtin/reward/v6.go index 010a3a870..37841e6cf 100644 --- a/chain/actors/builtin/reward/v6.go +++ b/chain/actors/builtin/reward/v6.go @@ -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 diff --git a/chain/actors/builtin/reward/v7.go b/chain/actors/builtin/reward/v7.go index 368bb3abd..66da5720a 100644 --- a/chain/actors/builtin/reward/v7.go +++ b/chain/actors/builtin/reward/v7.go @@ -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 diff --git a/chain/actors/builtin/reward/v8.go b/chain/actors/builtin/reward/v8.go index 23ebf6f57..6fce0c06a 100644 --- a/chain/actors/builtin/reward/v8.go +++ b/chain/actors/builtin/reward/v8.go @@ -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 diff --git a/chain/actors/builtin/system/system.go b/chain/actors/builtin/system/system.go index c4d00e8f1..f58711abb 100644 --- a/chain/actors/builtin/system/system.go +++ b/chain/actors/builtin/system/system.go @@ -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: diff --git a/chain/actors/builtin/system/v0.go b/chain/actors/builtin/system/v0.go index 64c6f53d3..4dee475bd 100644 --- a/chain/actors/builtin/system/v0.go +++ b/chain/actors/builtin/system/v0.go @@ -32,4 +32,4 @@ type state0 struct { func (s *state0) GetState() interface{} { return &s.State -} +} \ No newline at end of file diff --git a/chain/actors/builtin/system/v2.go b/chain/actors/builtin/system/v2.go index eb540891c..2389a5c22 100644 --- a/chain/actors/builtin/system/v2.go +++ b/chain/actors/builtin/system/v2.go @@ -32,4 +32,4 @@ type state2 struct { func (s *state2) GetState() interface{} { return &s.State -} +} \ No newline at end of file diff --git a/chain/actors/builtin/system/v3.go b/chain/actors/builtin/system/v3.go index 5b04e189e..20e4dc9b2 100644 --- a/chain/actors/builtin/system/v3.go +++ b/chain/actors/builtin/system/v3.go @@ -32,4 +32,4 @@ type state3 struct { func (s *state3) GetState() interface{} { return &s.State -} +} \ No newline at end of file diff --git a/chain/actors/builtin/system/v4.go b/chain/actors/builtin/system/v4.go index b6c924978..1d37b49f1 100644 --- a/chain/actors/builtin/system/v4.go +++ b/chain/actors/builtin/system/v4.go @@ -32,4 +32,4 @@ type state4 struct { func (s *state4) GetState() interface{} { return &s.State -} +} \ No newline at end of file diff --git a/chain/actors/builtin/system/v5.go b/chain/actors/builtin/system/v5.go index 77d2a8478..255ae7b83 100644 --- a/chain/actors/builtin/system/v5.go +++ b/chain/actors/builtin/system/v5.go @@ -32,4 +32,4 @@ type state5 struct { func (s *state5) GetState() interface{} { return &s.State -} +} \ No newline at end of file diff --git a/chain/actors/builtin/system/v6.go b/chain/actors/builtin/system/v6.go index 689620afb..c801985c7 100644 --- a/chain/actors/builtin/system/v6.go +++ b/chain/actors/builtin/system/v6.go @@ -32,4 +32,4 @@ type state6 struct { func (s *state6) GetState() interface{} { return &s.State -} +} \ No newline at end of file diff --git a/chain/actors/builtin/system/v7.go b/chain/actors/builtin/system/v7.go index 813add5fb..ca33d0314 100644 --- a/chain/actors/builtin/system/v7.go +++ b/chain/actors/builtin/system/v7.go @@ -32,4 +32,4 @@ type state7 struct { func (s *state7) GetState() interface{} { return &s.State -} +} \ No newline at end of file diff --git a/chain/actors/builtin/system/v8.go b/chain/actors/builtin/system/v8.go index b218c7a52..10f285bcc 100644 --- a/chain/actors/builtin/system/v8.go +++ b/chain/actors/builtin/system/v8.go @@ -32,4 +32,4 @@ type state8 struct { func (s *state8) GetState() interface{} { return &s.State -} +} \ No newline at end of file diff --git a/chain/actors/builtin/verifreg/v0.go b/chain/actors/builtin/verifreg/v0.go index dcd34c72a..e3bf72b70 100644 --- a/chain/actors/builtin/verifreg/v0.go +++ b/chain/actors/builtin/verifreg/v0.go @@ -25,14 +25,14 @@ func load0(store adt.Store, root cid.Cid) (State, error) { func make0(store adt.Store, rootKeyAddress address.Address) (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 - } - - out.State = *verifreg0.ConstructState(em, rootKeyAddress) - + out.State = *verifreg0.ConstructState(em, rootKeyAddress) + return &out, nil } @@ -74,10 +74,10 @@ func (s *state0) verifiers() (adt.Map, error) { } func (s *state0) removeDataCapProposalIDs() (adt.Map, error) { - return nil, nil - + return nil, nil + } func (s *state0) GetState() interface{} { return &s.State -} +} \ No newline at end of file diff --git a/chain/actors/builtin/verifreg/v2.go b/chain/actors/builtin/verifreg/v2.go index dfe25f054..557366ab6 100644 --- a/chain/actors/builtin/verifreg/v2.go +++ b/chain/actors/builtin/verifreg/v2.go @@ -25,14 +25,14 @@ func load2(store adt.Store, root cid.Cid) (State, error) { func make2(store adt.Store, rootKeyAddress address.Address) (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 - } - - out.State = *verifreg2.ConstructState(em, rootKeyAddress) - + out.State = *verifreg2.ConstructState(em, rootKeyAddress) + return &out, nil } @@ -74,10 +74,10 @@ func (s *state2) verifiers() (adt.Map, error) { } func (s *state2) removeDataCapProposalIDs() (adt.Map, error) { - return nil, nil - + return nil, nil + } func (s *state2) GetState() interface{} { return &s.State -} +} \ No newline at end of file diff --git a/chain/actors/builtin/verifreg/v3.go b/chain/actors/builtin/verifreg/v3.go index c71c69f92..90075dcf3 100644 --- a/chain/actors/builtin/verifreg/v3.go +++ b/chain/actors/builtin/verifreg/v3.go @@ -26,14 +26,14 @@ func load3(store adt.Store, root cid.Cid) (State, error) { func make3(store adt.Store, rootKeyAddress address.Address) (State, error) { out := state3{store: store} + + s, err := verifreg3.ConstructState(store, rootKeyAddress) + if err != nil { + return nil, err + } - s, err := verifreg3.ConstructState(store, rootKeyAddress) - if err != nil { - return nil, err - } - - out.State = *s - + out.State = *s + return &out, nil } @@ -75,10 +75,10 @@ func (s *state3) verifiers() (adt.Map, error) { } func (s *state3) removeDataCapProposalIDs() (adt.Map, error) { - return nil, nil - + return nil, nil + } func (s *state3) GetState() interface{} { return &s.State -} +} \ No newline at end of file diff --git a/chain/actors/builtin/verifreg/v4.go b/chain/actors/builtin/verifreg/v4.go index d3adc5169..dc730187d 100644 --- a/chain/actors/builtin/verifreg/v4.go +++ b/chain/actors/builtin/verifreg/v4.go @@ -26,14 +26,14 @@ func load4(store adt.Store, root cid.Cid) (State, error) { func make4(store adt.Store, rootKeyAddress address.Address) (State, error) { out := state4{store: store} + + s, err := verifreg4.ConstructState(store, rootKeyAddress) + if err != nil { + return nil, err + } - s, err := verifreg4.ConstructState(store, rootKeyAddress) - if err != nil { - return nil, err - } - - out.State = *s - + out.State = *s + return &out, nil } @@ -75,10 +75,10 @@ func (s *state4) verifiers() (adt.Map, error) { } func (s *state4) removeDataCapProposalIDs() (adt.Map, error) { - return nil, nil - + return nil, nil + } func (s *state4) GetState() interface{} { return &s.State -} +} \ No newline at end of file diff --git a/chain/actors/builtin/verifreg/v5.go b/chain/actors/builtin/verifreg/v5.go index 2af501af3..9d5035ffd 100644 --- a/chain/actors/builtin/verifreg/v5.go +++ b/chain/actors/builtin/verifreg/v5.go @@ -26,14 +26,14 @@ func load5(store adt.Store, root cid.Cid) (State, error) { func make5(store adt.Store, rootKeyAddress address.Address) (State, error) { out := state5{store: store} + + s, err := verifreg5.ConstructState(store, rootKeyAddress) + if err != nil { + return nil, err + } - s, err := verifreg5.ConstructState(store, rootKeyAddress) - if err != nil { - return nil, err - } - - out.State = *s - + out.State = *s + return &out, nil } @@ -75,10 +75,10 @@ func (s *state5) verifiers() (adt.Map, error) { } func (s *state5) removeDataCapProposalIDs() (adt.Map, error) { - return nil, nil - + return nil, nil + } func (s *state5) GetState() interface{} { return &s.State -} +} \ No newline at end of file diff --git a/chain/actors/builtin/verifreg/v6.go b/chain/actors/builtin/verifreg/v6.go index 454c9478f..30446d4b7 100644 --- a/chain/actors/builtin/verifreg/v6.go +++ b/chain/actors/builtin/verifreg/v6.go @@ -26,14 +26,14 @@ func load6(store adt.Store, root cid.Cid) (State, error) { func make6(store adt.Store, rootKeyAddress address.Address) (State, error) { out := state6{store: store} + + s, err := verifreg6.ConstructState(store, rootKeyAddress) + if err != nil { + return nil, err + } - s, err := verifreg6.ConstructState(store, rootKeyAddress) - if err != nil { - return nil, err - } - - out.State = *s - + out.State = *s + return &out, nil } @@ -75,10 +75,10 @@ func (s *state6) verifiers() (adt.Map, error) { } func (s *state6) removeDataCapProposalIDs() (adt.Map, error) { - return nil, nil - + return nil, nil + } func (s *state6) GetState() interface{} { return &s.State -} +} \ No newline at end of file diff --git a/chain/actors/builtin/verifreg/v7.go b/chain/actors/builtin/verifreg/v7.go index 3bcfa10bd..01de7e5ab 100644 --- a/chain/actors/builtin/verifreg/v7.go +++ b/chain/actors/builtin/verifreg/v7.go @@ -26,14 +26,14 @@ func load7(store adt.Store, root cid.Cid) (State, error) { func make7(store adt.Store, rootKeyAddress address.Address) (State, error) { out := state7{store: store} + + s, err := verifreg7.ConstructState(store, rootKeyAddress) + if err != nil { + return nil, err + } - s, err := verifreg7.ConstructState(store, rootKeyAddress) - if err != nil { - return nil, err - } - - out.State = *s - + out.State = *s + return &out, nil } @@ -75,9 +75,9 @@ func (s *state7) verifiers() (adt.Map, error) { } func (s *state7) removeDataCapProposalIDs() (adt.Map, error) { - return adt7.AsMap(s.store, s.RemoveDataCapProposalIDs, builtin7.DefaultHamtBitwidth) + return adt7.AsMap(s.store, s.RemoveDataCapProposalIDs, builtin7.DefaultHamtBitwidth) } func (s *state7) GetState() interface{} { return &s.State -} +} \ No newline at end of file diff --git a/chain/actors/builtin/verifreg/v8.go b/chain/actors/builtin/verifreg/v8.go index bb0b19909..1903d0fe4 100644 --- a/chain/actors/builtin/verifreg/v8.go +++ b/chain/actors/builtin/verifreg/v8.go @@ -26,14 +26,14 @@ func load8(store adt.Store, root cid.Cid) (State, error) { func make8(store adt.Store, rootKeyAddress address.Address) (State, error) { out := state8{store: store} + + s, err := verifreg8.ConstructState(store, rootKeyAddress) + if err != nil { + return nil, err + } - s, err := verifreg8.ConstructState(store, rootKeyAddress) - if err != nil { - return nil, err - } - - out.State = *s - + out.State = *s + return &out, nil } @@ -75,9 +75,9 @@ func (s *state8) verifiers() (adt.Map, error) { } func (s *state8) removeDataCapProposalIDs() (adt.Map, error) { - return adt8.AsMap(s.store, s.RemoveDataCapProposalIDs, builtin8.DefaultHamtBitwidth) + return adt8.AsMap(s.store, s.RemoveDataCapProposalIDs, builtin8.DefaultHamtBitwidth) } func (s *state8) GetState() interface{} { return &s.State -} +} \ No newline at end of file diff --git a/chain/actors/builtin/verifreg/verifreg.go b/chain/actors/builtin/verifreg/verifreg.go index 35f9db21c..c3d4f44a7 100644 --- a/chain/actors/builtin/verifreg/verifreg.go +++ b/chain/actors/builtin/verifreg/verifreg.go @@ -25,9 +25,10 @@ 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" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/types" verifreg8 "github.com/filecoin-project/specs-actors/v7/actors/builtin/verifreg" ) @@ -38,34 +39,82 @@ func init() { return load0(store, root) }) + if c, ok := actors.GetActorCodeID(actors.Version0, "verifiedregistry"); ok { + builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { + return load0(store, root) + }) + } + builtin.RegisterActorState(builtin2.VerifiedRegistryActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { return load2(store, root) }) + if c, ok := actors.GetActorCodeID(actors.Version2, "verifiedregistry"); ok { + builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { + return load2(store, root) + }) + } + builtin.RegisterActorState(builtin3.VerifiedRegistryActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { return load3(store, root) }) + if c, ok := actors.GetActorCodeID(actors.Version3, "verifiedregistry"); ok { + builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { + return load3(store, root) + }) + } + builtin.RegisterActorState(builtin4.VerifiedRegistryActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { return load4(store, root) }) + if c, ok := actors.GetActorCodeID(actors.Version4, "verifiedregistry"); ok { + builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { + return load4(store, root) + }) + } + builtin.RegisterActorState(builtin5.VerifiedRegistryActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { return load5(store, root) }) + if c, ok := actors.GetActorCodeID(actors.Version5, "verifiedregistry"); ok { + builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { + return load5(store, root) + }) + } + builtin.RegisterActorState(builtin6.VerifiedRegistryActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { return load6(store, root) }) + if c, ok := actors.GetActorCodeID(actors.Version6, "verifiedregistry"); ok { + builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { + return load6(store, root) + }) + } + builtin.RegisterActorState(builtin7.VerifiedRegistryActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { return load7(store, root) }) + if c, ok := actors.GetActorCodeID(actors.Version7, "verifiedregistry"); ok { + builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { + return load7(store, root) + }) + } + builtin.RegisterActorState(builtin8.VerifiedRegistryActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { return load8(store, root) }) + if c, ok := actors.GetActorCodeID(actors.Version8, "verifiedregistry"); ok { + builtin.RegisterActorState(c, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { + return load8(store, root) + }) + } + } var ( @@ -74,6 +123,42 @@ var ( ) func Load(store adt.Store, act *types.Actor) (State, error) { + if name, av, ok := actors.GetActorMetaByCode(act.Code); ok { + if name != "verifiedregistry" { + return nil, xerrors.Errorf("actor code is not verifiedregistry: %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.VerifiedRegistryActorCodeID: @@ -131,11 +216,15 @@ func MakeState(store adt.Store, av actors.Version, rootKeyAddress address.Addres case actors.Version8: return make8(store, rootKeyAddress) - } +} return nil, xerrors.Errorf("unknown actor version %d", av) } func GetActorCodeID(av actors.Version) (cid.Cid, error) { + if c, ok := actors.GetActorCodeID(av, "verifiedregistry"); ok { + return c, nil + } + switch av { case actors.Version0: @@ -171,7 +260,6 @@ type RemoveDataCapProposal = verifreg8.RemoveDataCapProposal type RemoveDataCapRequest = verifreg8.RemoveDataCapRequest type RemoveDataCapParams = verifreg8.RemoveDataCapParams type RmDcProposalID = verifreg8.RmDcProposalID - const SignatureDomainSeparation_RemoveDataCap = verifreg8.SignatureDomainSeparation_RemoveDataCap type State interface { diff --git a/chain/actors/policy/policy.go b/chain/actors/policy/policy.go index 673bbf57c..e48a79f24 100644 --- a/chain/actors/policy/policy.go +++ b/chain/actors/policy/policy.go @@ -10,45 +10,55 @@ import ( "github.com/filecoin-project/go-state-types/network" "github.com/filecoin-project/lotus/chain/actors" + + market0 "github.com/filecoin-project/specs-actors/actors/builtin/market" miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner" - power0 "github.com/filecoin-project/specs-actors/actors/builtin/power" verifreg0 "github.com/filecoin-project/specs-actors/actors/builtin/verifreg" - - builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin" + power0 "github.com/filecoin-project/specs-actors/actors/builtin/power" + + builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin" market2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/market" miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner" verifreg2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/verifreg" - - builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin" + + + builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin" market3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/market" miner3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/miner" verifreg3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/verifreg" - - builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin" + + + builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin" market4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/market" miner4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/miner" verifreg4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/verifreg" - - builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin" + + + builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin" market5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/market" miner5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/miner" verifreg5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/verifreg" - - builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin" + + + builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin" market6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/market" miner6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/miner" verifreg6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/verifreg" - - builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" + + + builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" market7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/market" miner7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/miner" verifreg7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/verifreg" - - builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin" + + + builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin" market8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/market" miner8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/miner" verifreg8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/verifreg" + + paych8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/paych" ) @@ -63,28 +73,45 @@ const ( // SetSupportedProofTypes sets supported proof types, across all actor versions. // This should only be used for testing. func SetSupportedProofTypes(types ...abi.RegisteredSealProof) { - - miner0.SupportedProofTypes = make(map[abi.RegisteredSealProof]struct{}, len(types)) - - miner2.PreCommitSealProofTypesV0 = make(map[abi.RegisteredSealProof]struct{}, len(types)) - miner2.PreCommitSealProofTypesV7 = make(map[abi.RegisteredSealProof]struct{}, len(types)*2) - miner2.PreCommitSealProofTypesV8 = make(map[abi.RegisteredSealProof]struct{}, len(types)) - - miner3.PreCommitSealProofTypesV0 = make(map[abi.RegisteredSealProof]struct{}, len(types)) - miner3.PreCommitSealProofTypesV7 = make(map[abi.RegisteredSealProof]struct{}, len(types)*2) - miner3.PreCommitSealProofTypesV8 = make(map[abi.RegisteredSealProof]struct{}, len(types)) - - miner4.PreCommitSealProofTypesV0 = make(map[abi.RegisteredSealProof]struct{}, len(types)) - miner4.PreCommitSealProofTypesV7 = make(map[abi.RegisteredSealProof]struct{}, len(types)*2) - miner4.PreCommitSealProofTypesV8 = make(map[abi.RegisteredSealProof]struct{}, len(types)) - - miner5.PreCommitSealProofTypesV8 = make(map[abi.RegisteredSealProof]struct{}, len(types)) - - miner6.PreCommitSealProofTypesV8 = make(map[abi.RegisteredSealProof]struct{}, len(types)) - - miner7.PreCommitSealProofTypesV8 = make(map[abi.RegisteredSealProof]struct{}, len(types)) - - miner8.PreCommitSealProofTypesV8 = make(map[abi.RegisteredSealProof]struct{}, len(types)) + + + miner0.SupportedProofTypes = make(map[abi.RegisteredSealProof]struct{}, len(types)) + + + + miner2.PreCommitSealProofTypesV0 = make(map[abi.RegisteredSealProof]struct{}, len(types)) + miner2.PreCommitSealProofTypesV7 = make(map[abi.RegisteredSealProof]struct{}, len(types)*2) + miner2.PreCommitSealProofTypesV8 = make(map[abi.RegisteredSealProof]struct{}, len(types)) + + + + miner3.PreCommitSealProofTypesV0 = make(map[abi.RegisteredSealProof]struct{}, len(types)) + miner3.PreCommitSealProofTypesV7 = make(map[abi.RegisteredSealProof]struct{}, len(types)*2) + miner3.PreCommitSealProofTypesV8 = make(map[abi.RegisteredSealProof]struct{}, len(types)) + + + + miner4.PreCommitSealProofTypesV0 = make(map[abi.RegisteredSealProof]struct{}, len(types)) + miner4.PreCommitSealProofTypesV7 = make(map[abi.RegisteredSealProof]struct{}, len(types)*2) + miner4.PreCommitSealProofTypesV8 = make(map[abi.RegisteredSealProof]struct{}, len(types)) + + + + miner5.PreCommitSealProofTypesV8 = make(map[abi.RegisteredSealProof]struct{}, len(types)) + + + + miner6.PreCommitSealProofTypesV8 = make(map[abi.RegisteredSealProof]struct{}, len(types)) + + + + miner7.PreCommitSealProofTypesV8 = make(map[abi.RegisteredSealProof]struct{}, len(types)) + + + + miner8.PreCommitSealProofTypesV8 = make(map[abi.RegisteredSealProof]struct{}, len(types)) + + AddSupportedProofTypes(types...) } @@ -98,59 +125,76 @@ func AddSupportedProofTypes(types ...abi.RegisteredSealProof) { } // Set for all miner versions. - miner0.SupportedProofTypes[t] = struct{}{} + + + miner0.SupportedProofTypes[t] = struct{}{} + + + + miner2.PreCommitSealProofTypesV0[t] = struct{}{} + miner2.PreCommitSealProofTypesV7[t] = struct{}{} + miner2.PreCommitSealProofTypesV7[t+abi.RegisteredSealProof_StackedDrg2KiBV1_1] = struct{}{} + miner2.PreCommitSealProofTypesV8[t+abi.RegisteredSealProof_StackedDrg2KiBV1_1] = struct{}{} + + + + miner3.PreCommitSealProofTypesV0[t] = struct{}{} + miner3.PreCommitSealProofTypesV7[t] = struct{}{} + miner3.PreCommitSealProofTypesV7[t+abi.RegisteredSealProof_StackedDrg2KiBV1_1] = struct{}{} + miner3.PreCommitSealProofTypesV8[t+abi.RegisteredSealProof_StackedDrg2KiBV1_1] = struct{}{} + + + + miner4.PreCommitSealProofTypesV0[t] = struct{}{} + miner4.PreCommitSealProofTypesV7[t] = struct{}{} + miner4.PreCommitSealProofTypesV7[t+abi.RegisteredSealProof_StackedDrg2KiBV1_1] = struct{}{} + miner4.PreCommitSealProofTypesV8[t+abi.RegisteredSealProof_StackedDrg2KiBV1_1] = struct{}{} + + + + miner5.PreCommitSealProofTypesV8[t+abi.RegisteredSealProof_StackedDrg2KiBV1_1] = struct{}{} + wpp, err := t.RegisteredWindowPoStProof() + if err != nil { + // Fine to panic, this is a test-only method + panic(err) + } - miner2.PreCommitSealProofTypesV0[t] = struct{}{} - miner2.PreCommitSealProofTypesV7[t] = struct{}{} - miner2.PreCommitSealProofTypesV7[t+abi.RegisteredSealProof_StackedDrg2KiBV1_1] = struct{}{} - miner2.PreCommitSealProofTypesV8[t+abi.RegisteredSealProof_StackedDrg2KiBV1_1] = struct{}{} + miner5.WindowPoStProofTypes[wpp] = struct{}{} + + + + miner6.PreCommitSealProofTypesV8[t+abi.RegisteredSealProof_StackedDrg2KiBV1_1] = struct{}{} + wpp, err = t.RegisteredWindowPoStProof() + if err != nil { + // Fine to panic, this is a test-only method + panic(err) + } - miner3.PreCommitSealProofTypesV0[t] = struct{}{} - miner3.PreCommitSealProofTypesV7[t] = struct{}{} - miner3.PreCommitSealProofTypesV7[t+abi.RegisteredSealProof_StackedDrg2KiBV1_1] = struct{}{} - miner3.PreCommitSealProofTypesV8[t+abi.RegisteredSealProof_StackedDrg2KiBV1_1] = struct{}{} + miner6.WindowPoStProofTypes[wpp] = struct{}{} + + + + miner7.PreCommitSealProofTypesV8[t+abi.RegisteredSealProof_StackedDrg2KiBV1_1] = struct{}{} + wpp, err = t.RegisteredWindowPoStProof() + if err != nil { + // Fine to panic, this is a test-only method + panic(err) + } - miner4.PreCommitSealProofTypesV0[t] = struct{}{} - miner4.PreCommitSealProofTypesV7[t] = struct{}{} - miner4.PreCommitSealProofTypesV7[t+abi.RegisteredSealProof_StackedDrg2KiBV1_1] = struct{}{} - miner4.PreCommitSealProofTypesV8[t+abi.RegisteredSealProof_StackedDrg2KiBV1_1] = struct{}{} - - miner5.PreCommitSealProofTypesV8[t+abi.RegisteredSealProof_StackedDrg2KiBV1_1] = struct{}{} - wpp, err := t.RegisteredWindowPoStProof() - if err != nil { - // Fine to panic, this is a test-only method - panic(err) - } - - miner5.WindowPoStProofTypes[wpp] = struct{}{} - - miner6.PreCommitSealProofTypesV8[t+abi.RegisteredSealProof_StackedDrg2KiBV1_1] = struct{}{} - wpp, err = t.RegisteredWindowPoStProof() - if err != nil { - // Fine to panic, this is a test-only method - panic(err) - } - - miner6.WindowPoStProofTypes[wpp] = struct{}{} - - miner7.PreCommitSealProofTypesV8[t+abi.RegisteredSealProof_StackedDrg2KiBV1_1] = struct{}{} - wpp, err = t.RegisteredWindowPoStProof() - if err != nil { - // Fine to panic, this is a test-only method - panic(err) - } - - miner7.WindowPoStProofTypes[wpp] = struct{}{} - - miner8.PreCommitSealProofTypesV8[t+abi.RegisteredSealProof_StackedDrg2KiBV1_1] = struct{}{} - wpp, err = t.RegisteredWindowPoStProof() - if err != nil { - // Fine to panic, this is a test-only method - panic(err) - } - - miner8.WindowPoStProofTypes[wpp] = struct{}{} + miner7.WindowPoStProofTypes[wpp] = struct{}{} + + + + miner8.PreCommitSealProofTypesV8[t+abi.RegisteredSealProof_StackedDrg2KiBV1_1] = struct{}{} + wpp, err = t.RegisteredWindowPoStProof() + if err != nil { + // Fine to panic, this is a test-only method + panic(err) + } + miner8.WindowPoStProofTypes[wpp] = struct{}{} + + } } @@ -158,23 +202,23 @@ func AddSupportedProofTypes(types ...abi.RegisteredSealProof) { // actors versions. Use for testing. func SetPreCommitChallengeDelay(delay abi.ChainEpoch) { // Set for all miner versions. - - miner0.PreCommitChallengeDelay = delay - - miner2.PreCommitChallengeDelay = delay - - miner3.PreCommitChallengeDelay = delay - - miner4.PreCommitChallengeDelay = delay - - miner5.PreCommitChallengeDelay = delay - - miner6.PreCommitChallengeDelay = delay - - miner7.PreCommitChallengeDelay = delay - - miner8.PreCommitChallengeDelay = delay - + + miner0.PreCommitChallengeDelay = delay + + miner2.PreCommitChallengeDelay = delay + + miner3.PreCommitChallengeDelay = delay + + miner4.PreCommitChallengeDelay = delay + + miner5.PreCommitChallengeDelay = delay + + miner6.PreCommitChallengeDelay = delay + + miner7.PreCommitChallengeDelay = delay + + miner8.PreCommitChallengeDelay = delay + } // TODO: this function shouldn't really exist. Instead, the API should expose the precommit delay. @@ -186,96 +230,120 @@ func GetPreCommitChallengeDelay() abi.ChainEpoch { // meet for leader election, across all actor versions. This should only be used // for testing. func SetConsensusMinerMinPower(p abi.StoragePower) { - - power0.ConsensusMinerMinPower = p - - for _, policy := range builtin2.SealProofPolicies { - policy.ConsensusMinerMinPower = p - } - - for _, policy := range builtin3.PoStProofPolicies { - policy.ConsensusMinerMinPower = p - } - - for _, policy := range builtin4.PoStProofPolicies { - policy.ConsensusMinerMinPower = p - } - - for _, policy := range builtin5.PoStProofPolicies { - policy.ConsensusMinerMinPower = p - } - - for _, policy := range builtin6.PoStProofPolicies { - policy.ConsensusMinerMinPower = p - } - - for _, policy := range builtin7.PoStProofPolicies { - policy.ConsensusMinerMinPower = p - } - - for _, policy := range builtin8.PoStProofPolicies { - policy.ConsensusMinerMinPower = p - } - + + + power0.ConsensusMinerMinPower = p + + + + for _, policy := range builtin2.SealProofPolicies { + policy.ConsensusMinerMinPower = p + } + + + + for _, policy := range builtin3.PoStProofPolicies { + policy.ConsensusMinerMinPower = p + } + + + + for _, policy := range builtin4.PoStProofPolicies { + policy.ConsensusMinerMinPower = p + } + + + + for _, policy := range builtin5.PoStProofPolicies { + policy.ConsensusMinerMinPower = p + } + + + + for _, policy := range builtin6.PoStProofPolicies { + policy.ConsensusMinerMinPower = p + } + + + + for _, policy := range builtin7.PoStProofPolicies { + policy.ConsensusMinerMinPower = p + } + + + + for _, policy := range builtin8.PoStProofPolicies { + policy.ConsensusMinerMinPower = p + } + + } // SetMinVerifiedDealSize sets the minimum size of a verified deal. This should // only be used for testing. func SetMinVerifiedDealSize(size abi.StoragePower) { - - verifreg0.MinVerifiedDealSize = size - - verifreg2.MinVerifiedDealSize = size - - verifreg3.MinVerifiedDealSize = size - - verifreg4.MinVerifiedDealSize = size - - verifreg5.MinVerifiedDealSize = size - - verifreg6.MinVerifiedDealSize = size - - verifreg7.MinVerifiedDealSize = size - - verifreg8.MinVerifiedDealSize = size - + + verifreg0.MinVerifiedDealSize = size + + verifreg2.MinVerifiedDealSize = size + + verifreg3.MinVerifiedDealSize = size + + verifreg4.MinVerifiedDealSize = size + + verifreg5.MinVerifiedDealSize = size + + verifreg6.MinVerifiedDealSize = size + + verifreg7.MinVerifiedDealSize = size + + verifreg8.MinVerifiedDealSize = size + } func GetMaxProveCommitDuration(ver actors.Version, t abi.RegisteredSealProof) (abi.ChainEpoch, error) { switch ver { - - case actors.Version0: - - return miner0.MaxSealDuration[t], nil - - case actors.Version2: - - return miner2.MaxProveCommitDuration[t], nil - - case actors.Version3: - - return miner3.MaxProveCommitDuration[t], nil - - case actors.Version4: - - return miner4.MaxProveCommitDuration[t], nil - - case actors.Version5: - - return miner5.MaxProveCommitDuration[t], nil - - case actors.Version6: - - return miner6.MaxProveCommitDuration[t], nil - - case actors.Version7: - - return miner7.MaxProveCommitDuration[t], nil - - case actors.Version8: - - return miner8.MaxProveCommitDuration[t], nil - + + case actors.Version0: + + return miner0.MaxSealDuration[t], nil + + + case actors.Version2: + + return miner2.MaxProveCommitDuration[t], nil + + + case actors.Version3: + + return miner3.MaxProveCommitDuration[t], nil + + + case actors.Version4: + + return miner4.MaxProveCommitDuration[t], nil + + + case actors.Version5: + + return miner5.MaxProveCommitDuration[t], nil + + + case actors.Version6: + + return miner6.MaxProveCommitDuration[t], nil + + + case actors.Version7: + + return miner7.MaxProveCommitDuration[t], nil + + + case actors.Version8: + + return miner8.MaxProveCommitDuration[t], nil + + default: return 0, xerrors.Errorf("unsupported actors version") } @@ -286,40 +354,56 @@ func GetMaxProveCommitDuration(ver actors.Version, t abi.RegisteredSealProof) (a // only be used for testing. func SetProviderCollateralSupplyTarget(num, denom big.Int) { + + + market2.ProviderCollateralSupplyTarget = builtin2.BigFrac{ Numerator: num, Denominator: denom, } + + market3.ProviderCollateralSupplyTarget = builtin3.BigFrac{ Numerator: num, Denominator: denom, } + + market4.ProviderCollateralSupplyTarget = builtin4.BigFrac{ Numerator: num, Denominator: denom, } + + market5.ProviderCollateralSupplyTarget = builtin5.BigFrac{ Numerator: num, Denominator: denom, } + + market6.ProviderCollateralSupplyTarget = builtin6.BigFrac{ Numerator: num, Denominator: denom, } + + market7.ProviderCollateralSupplyTarget = builtin7.BigFrac{ Numerator: num, Denominator: denom, } + + market8.ProviderCollateralSupplyTarget = builtin8.BigFrac{ Numerator: num, Denominator: denom, } + } @@ -333,47 +417,55 @@ func DealProviderCollateralBounds( return big.Zero(), big.Zero(), err } switch v { - - case actors.Version0: - - min, max := market0.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil, nwVer) - return min, max, nil - - case actors.Version2: - - min, max := market2.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil) - return min, max, nil - - case actors.Version3: - - min, max := market3.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil) - return min, max, nil - - case actors.Version4: - - min, max := market4.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil) - return min, max, nil - - case actors.Version5: - - min, max := market5.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil) - return min, max, nil - - case actors.Version6: - - min, max := market6.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil) - return min, max, nil - - case actors.Version7: - - min, max := market7.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil) - return min, max, nil - - case actors.Version8: - - min, max := market8.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil) - return min, max, nil - + + case actors.Version0: + + min, max := market0.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil, nwVer) + return min, max, nil + + + case actors.Version2: + + min, max := market2.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil) + return min, max, nil + + + case actors.Version3: + + min, max := market3.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil) + return min, max, nil + + + case actors.Version4: + + min, max := market4.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil) + return min, max, nil + + + case actors.Version5: + + min, max := market5.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil) + return min, max, nil + + + case actors.Version6: + + min, max := market6.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil) + return min, max, nil + + + case actors.Version7: + + min, max := market7.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil) + return min, max, nil + + + case actors.Version8: + + min, max := market8.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil) + return min, max, nil + + default: return big.Zero(), big.Zero(), xerrors.Errorf("unsupported actors version") } @@ -386,55 +478,63 @@ func DealDurationBounds(pieceSize abi.PaddedPieceSize) (min, max abi.ChainEpoch) // Sets the challenge window and scales the proving period to match (such that // there are always 48 challenge windows in a proving period). func SetWPoStChallengeWindow(period abi.ChainEpoch) { - - miner0.WPoStChallengeWindow = period - miner0.WPoStProvingPeriod = period * abi.ChainEpoch(miner0.WPoStPeriodDeadlines) - - miner2.WPoStChallengeWindow = period - miner2.WPoStProvingPeriod = period * abi.ChainEpoch(miner2.WPoStPeriodDeadlines) - - miner3.WPoStChallengeWindow = period - miner3.WPoStProvingPeriod = period * abi.ChainEpoch(miner3.WPoStPeriodDeadlines) - - // by default, this is 2x finality which is 30 periods. - // scale it if we're scaling the challenge period. - miner3.WPoStDisputeWindow = period * 30 - - miner4.WPoStChallengeWindow = period - miner4.WPoStProvingPeriod = period * abi.ChainEpoch(miner4.WPoStPeriodDeadlines) - - // by default, this is 2x finality which is 30 periods. - // scale it if we're scaling the challenge period. - miner4.WPoStDisputeWindow = period * 30 - - miner5.WPoStChallengeWindow = period - miner5.WPoStProvingPeriod = period * abi.ChainEpoch(miner5.WPoStPeriodDeadlines) - - // by default, this is 2x finality which is 30 periods. - // scale it if we're scaling the challenge period. - miner5.WPoStDisputeWindow = period * 30 - - miner6.WPoStChallengeWindow = period - miner6.WPoStProvingPeriod = period * abi.ChainEpoch(miner6.WPoStPeriodDeadlines) - - // by default, this is 2x finality which is 30 periods. - // scale it if we're scaling the challenge period. - miner6.WPoStDisputeWindow = period * 30 - - miner7.WPoStChallengeWindow = period - miner7.WPoStProvingPeriod = period * abi.ChainEpoch(miner7.WPoStPeriodDeadlines) - - // by default, this is 2x finality which is 30 periods. - // scale it if we're scaling the challenge period. - miner7.WPoStDisputeWindow = period * 30 - - miner8.WPoStChallengeWindow = period - miner8.WPoStProvingPeriod = period * abi.ChainEpoch(miner8.WPoStPeriodDeadlines) - - // by default, this is 2x finality which is 30 periods. - // scale it if we're scaling the challenge period. - miner8.WPoStDisputeWindow = period * 30 - + + miner0.WPoStChallengeWindow = period + miner0.WPoStProvingPeriod = period * abi.ChainEpoch(miner0.WPoStPeriodDeadlines) + + + miner2.WPoStChallengeWindow = period + miner2.WPoStProvingPeriod = period * abi.ChainEpoch(miner2.WPoStPeriodDeadlines) + + + miner3.WPoStChallengeWindow = period + miner3.WPoStProvingPeriod = period * abi.ChainEpoch(miner3.WPoStPeriodDeadlines) + + // by default, this is 2x finality which is 30 periods. + // scale it if we're scaling the challenge period. + miner3.WPoStDisputeWindow = period * 30 + + + miner4.WPoStChallengeWindow = period + miner4.WPoStProvingPeriod = period * abi.ChainEpoch(miner4.WPoStPeriodDeadlines) + + // by default, this is 2x finality which is 30 periods. + // scale it if we're scaling the challenge period. + miner4.WPoStDisputeWindow = period * 30 + + + miner5.WPoStChallengeWindow = period + miner5.WPoStProvingPeriod = period * abi.ChainEpoch(miner5.WPoStPeriodDeadlines) + + // by default, this is 2x finality which is 30 periods. + // scale it if we're scaling the challenge period. + miner5.WPoStDisputeWindow = period * 30 + + + miner6.WPoStChallengeWindow = period + miner6.WPoStProvingPeriod = period * abi.ChainEpoch(miner6.WPoStPeriodDeadlines) + + // by default, this is 2x finality which is 30 periods. + // scale it if we're scaling the challenge period. + miner6.WPoStDisputeWindow = period * 30 + + + miner7.WPoStChallengeWindow = period + miner7.WPoStProvingPeriod = period * abi.ChainEpoch(miner7.WPoStPeriodDeadlines) + + // by default, this is 2x finality which is 30 periods. + // scale it if we're scaling the challenge period. + miner7.WPoStDisputeWindow = period * 30 + + + miner8.WPoStChallengeWindow = period + miner8.WPoStProvingPeriod = period * abi.ChainEpoch(miner8.WPoStPeriodDeadlines) + + // by default, this is 2x finality which is 30 periods. + // scale it if we're scaling the challenge period. + miner8.WPoStDisputeWindow = period * 30 + + } func GetWinningPoStSectorSetLookback(nwVer network.Version) abi.ChainEpoch { @@ -503,31 +603,31 @@ func GetAddressedSectorsMax(nwVer network.Version) (int, error) { return 0, err } switch v { - - case actors.Version0: - return miner0.AddressedSectorsMax, nil - - case actors.Version2: - return miner2.AddressedSectorsMax, nil - - case actors.Version3: - return miner3.AddressedSectorsMax, nil - - case actors.Version4: - return miner4.AddressedSectorsMax, nil - - case actors.Version5: - return miner5.AddressedSectorsMax, nil - - case actors.Version6: - return miner6.AddressedSectorsMax, nil - - case actors.Version7: - return miner7.AddressedSectorsMax, nil - - case actors.Version8: - return miner8.AddressedSectorsMax, nil - + + case actors.Version0: + return miner0.AddressedSectorsMax, nil + + case actors.Version2: + return miner2.AddressedSectorsMax, nil + + case actors.Version3: + return miner3.AddressedSectorsMax, nil + + case actors.Version4: + return miner4.AddressedSectorsMax, nil + + case actors.Version5: + return miner5.AddressedSectorsMax, nil + + case actors.Version6: + return miner6.AddressedSectorsMax, nil + + case actors.Version7: + return miner7.AddressedSectorsMax, nil + + case actors.Version8: + return miner8.AddressedSectorsMax, nil + default: return 0, xerrors.Errorf("unsupported network version") } @@ -539,128 +639,152 @@ func GetDeclarationsMax(nwVer network.Version) (int, error) { return 0, err } switch v { - - case actors.Version0: - - // TODO: Should we instead error here since the concept doesn't exist yet? - return miner0.AddressedPartitionsMax, nil - - case actors.Version2: - - return miner2.DeclarationsMax, nil - - case actors.Version3: - - return miner3.DeclarationsMax, nil - - case actors.Version4: - - return miner4.DeclarationsMax, nil - - case actors.Version5: - - return miner5.DeclarationsMax, nil - - case actors.Version6: - - return miner6.DeclarationsMax, nil - - case actors.Version7: - - return miner7.DeclarationsMax, nil - - case actors.Version8: - - return miner8.DeclarationsMax, nil - + + case actors.Version0: + + // TODO: Should we instead error here since the concept doesn't exist yet? + return miner0.AddressedPartitionsMax, nil + + + case actors.Version2: + + return miner2.DeclarationsMax, nil + + + case actors.Version3: + + return miner3.DeclarationsMax, nil + + + case actors.Version4: + + return miner4.DeclarationsMax, nil + + + case actors.Version5: + + return miner5.DeclarationsMax, nil + + + case actors.Version6: + + return miner6.DeclarationsMax, nil + + + case actors.Version7: + + return miner7.DeclarationsMax, nil + + + case actors.Version8: + + return miner8.DeclarationsMax, nil + + default: return 0, xerrors.Errorf("unsupported network version") } } func AggregateProveCommitNetworkFee(nwVer network.Version, aggregateSize int, baseFee abi.TokenAmount) (abi.TokenAmount, error) { - v, err := actors.VersionForNetwork(nwVer) + v, err := actors.VersionForNetwork(nwVer) if err != nil { return big.Zero(), err } switch v { - - case actors.Version0: - - return big.Zero(), nil - - case actors.Version2: - - return big.Zero(), nil - - case actors.Version3: - - return big.Zero(), nil - - case actors.Version4: - - return big.Zero(), nil - - case actors.Version5: - - return miner5.AggregateNetworkFee(aggregateSize, baseFee), nil - - case actors.Version6: - - return miner6.AggregateProveCommitNetworkFee(aggregateSize, baseFee), nil - - case actors.Version7: - - return miner7.AggregateProveCommitNetworkFee(aggregateSize, baseFee), nil - - case actors.Version8: - - return miner8.AggregateProveCommitNetworkFee(aggregateSize, baseFee), nil - + + case actors.Version0: + + return big.Zero(), nil + + + case actors.Version2: + + return big.Zero(), nil + + + case actors.Version3: + + return big.Zero(), nil + + + case actors.Version4: + + return big.Zero(), nil + + + case actors.Version5: + + return miner5.AggregateNetworkFee(aggregateSize, baseFee), nil + + + case actors.Version6: + + return miner6.AggregateProveCommitNetworkFee(aggregateSize, baseFee), nil + + + case actors.Version7: + + return miner7.AggregateProveCommitNetworkFee(aggregateSize, baseFee), nil + + + case actors.Version8: + + return miner8.AggregateProveCommitNetworkFee(aggregateSize, baseFee), nil + + default: return big.Zero(), xerrors.Errorf("unsupported network version") } } func AggregatePreCommitNetworkFee(nwVer network.Version, aggregateSize int, baseFee abi.TokenAmount) (abi.TokenAmount, error) { - v, err := actors.VersionForNetwork(nwVer) + v, err := actors.VersionForNetwork(nwVer) if err != nil { return big.Zero(), err } switch v { - - case actors.Version0: - - return big.Zero(), nil - - case actors.Version2: - - return big.Zero(), nil - - case actors.Version3: - - return big.Zero(), nil - - case actors.Version4: - - return big.Zero(), nil - - case actors.Version5: - - return big.Zero(), nil - - case actors.Version6: - - return miner6.AggregatePreCommitNetworkFee(aggregateSize, baseFee), nil - - case actors.Version7: - - return miner7.AggregatePreCommitNetworkFee(aggregateSize, baseFee), nil - - case actors.Version8: - - return miner8.AggregatePreCommitNetworkFee(aggregateSize, baseFee), nil - + + case actors.Version0: + + return big.Zero(), nil + + + case actors.Version2: + + return big.Zero(), nil + + + case actors.Version3: + + return big.Zero(), nil + + + case actors.Version4: + + return big.Zero(), nil + + + case actors.Version5: + + return big.Zero(), nil + + + case actors.Version6: + + return miner6.AggregatePreCommitNetworkFee(aggregateSize, baseFee), nil + + + case actors.Version7: + + return miner7.AggregatePreCommitNetworkFee(aggregateSize, baseFee), nil + + + case actors.Version8: + + return miner8.AggregatePreCommitNetworkFee(aggregateSize, baseFee), nil + + default: return big.Zero(), xerrors.Errorf("unsupported network version") }