Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to actors master #7404

Merged
merged 4 commits into from
Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion chain/actors/builtin/market/actor.go.template
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package market

import (
"github.com/filecoin-project/go-state-types/network"
"golang.org/x/xerrors"

"github.com/filecoin-project/go-address"
Expand Down Expand Up @@ -103,7 +104,28 @@ type DealProposals interface {
}

type PublishStorageDealsParams = market0.PublishStorageDealsParams
type PublishStorageDealsReturn = market0.PublishStorageDealsReturn

type PublishStorageDealsReturn interface {
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)
}

func DecodePublishStorageDealsReturn(b []byte, nv network.Version) (PublishStorageDealsReturn, error) {
av, err := actors.VersionForNetwork(nv)
if err != nil {
return nil, err
}

switch av {
{{range .versions}}
case actors.Version{{.}}:
return decodePublishStorageDealsReturn{{.}}(b)
{{end}}
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}

type VerifyDealsForActivationParams = market0.VerifyDealsForActivationParams
type WithdrawBalanceParams = market0.WithdrawBalanceParams

Expand Down
39 changes: 38 additions & 1 deletion chain/actors/builtin/market/market.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package market

import (
"github.com/filecoin-project/go-state-types/network"
"golang.org/x/xerrors"

"github.com/filecoin-project/go-address"
Expand Down Expand Up @@ -177,7 +178,43 @@ type DealProposals interface {
}

type PublishStorageDealsParams = market0.PublishStorageDealsParams
type PublishStorageDealsReturn = market0.PublishStorageDealsReturn

type PublishStorageDealsReturn interface {
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)
}

func DecodePublishStorageDealsReturn(b []byte, nv network.Version) (PublishStorageDealsReturn, error) {
av, err := actors.VersionForNetwork(nv)
if err != nil {
return nil, err
}

switch av {

case actors.Version0:
return decodePublishStorageDealsReturn0(b)

case actors.Version2:
return decodePublishStorageDealsReturn2(b)

case actors.Version3:
return decodePublishStorageDealsReturn3(b)

case actors.Version4:
return decodePublishStorageDealsReturn4(b)

case actors.Version5:
return decodePublishStorageDealsReturn5(b)

case actors.Version6:
return decodePublishStorageDealsReturn6(b)

}
return nil, xerrors.Errorf("unknown actor version %d", av)
}

type VerifyDealsForActivationParams = market0.VerifyDealsForActivationParams
type WithdrawBalanceParams = market0.WithdrawBalanceParams

Expand Down
29 changes: 29 additions & 0 deletions chain/actors/builtin/market/state.go.template
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/filecoin-project/go-state-types/abi"
"github.com/ipfs/go-cid"
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors"

"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/types"
Expand Down Expand Up @@ -236,3 +237,31 @@ func fromV{{.v}}DealProposal(v{{.v}} market{{.v}}.DealProposal) DealProposal {
func (s *state{{.v}}) GetState() interface{} {
return &s.State
}

var _ PublishStorageDealsReturn = (*publishStorageDealsReturn{{.v}})(nil)

func decodePublishStorageDealsReturn{{.v}}(b []byte) (PublishStorageDealsReturn, error) {
var retval market{{.v}}.PublishStorageDealsReturn
if err := retval.UnmarshalCBOR(bytes.NewReader(b)); err != nil {
return nil, xerrors.Errorf("failed to unmarshal PublishStorageDealsReturn: %w", err)
}

return &publishStorageDealsReturn{{.v}}{retval}, nil
}

type publishStorageDealsReturn{{.v}} struct {
market{{.v}}.PublishStorageDealsReturn
}

func (r *publishStorageDealsReturn{{.v}}) IsDealValid(index uint64) (bool, error) {
{{if (ge .v 6)}}
return r.ValidDeals.IsSet(index)
{{else}}
// PublishStorageDeals only succeeded if all deals were valid in this version of actors
return true, nil
{{end}}
}

func (r *publishStorageDealsReturn{{.v}}) DealIDs() ([]abi.DealID, error) {
return r.IDs, nil
}
27 changes: 27 additions & 0 deletions chain/actors/builtin/market/v0.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/filecoin-project/go-state-types/abi"
"github.com/ipfs/go-cid"
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors"

"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/types"
Expand Down Expand Up @@ -229,3 +230,29 @@ func fromV0DealProposal(v0 market0.DealProposal) DealProposal {
func (s *state0) GetState() interface{} {
return &s.State
}

var _ PublishStorageDealsReturn = (*publishStorageDealsReturn0)(nil)

func decodePublishStorageDealsReturn0(b []byte) (PublishStorageDealsReturn, error) {
var retval market0.PublishStorageDealsReturn
if err := retval.UnmarshalCBOR(bytes.NewReader(b)); err != nil {
return nil, xerrors.Errorf("failed to unmarshal PublishStorageDealsReturn: %w", err)
}

return &publishStorageDealsReturn0{retval}, nil
}

type publishStorageDealsReturn0 struct {
market0.PublishStorageDealsReturn
}

func (r *publishStorageDealsReturn0) IsDealValid(index uint64) (bool, error) {

// 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
}
27 changes: 27 additions & 0 deletions chain/actors/builtin/market/v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/filecoin-project/go-state-types/abi"
"github.com/ipfs/go-cid"
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors"

"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/types"
Expand Down Expand Up @@ -229,3 +230,29 @@ func fromV2DealProposal(v2 market2.DealProposal) DealProposal {
func (s *state2) GetState() interface{} {
return &s.State
}

var _ PublishStorageDealsReturn = (*publishStorageDealsReturn2)(nil)

func decodePublishStorageDealsReturn2(b []byte) (PublishStorageDealsReturn, error) {
var retval market2.PublishStorageDealsReturn
if err := retval.UnmarshalCBOR(bytes.NewReader(b)); err != nil {
return nil, xerrors.Errorf("failed to unmarshal PublishStorageDealsReturn: %w", err)
}

return &publishStorageDealsReturn2{retval}, nil
}

type publishStorageDealsReturn2 struct {
market2.PublishStorageDealsReturn
}

func (r *publishStorageDealsReturn2) IsDealValid(index uint64) (bool, error) {

// 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
}
27 changes: 27 additions & 0 deletions chain/actors/builtin/market/v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/filecoin-project/go-state-types/abi"
"github.com/ipfs/go-cid"
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors"

"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/types"
Expand Down Expand Up @@ -224,3 +225,29 @@ func fromV3DealProposal(v3 market3.DealProposal) DealProposal {
func (s *state3) GetState() interface{} {
return &s.State
}

var _ PublishStorageDealsReturn = (*publishStorageDealsReturn3)(nil)

func decodePublishStorageDealsReturn3(b []byte) (PublishStorageDealsReturn, error) {
var retval market3.PublishStorageDealsReturn
if err := retval.UnmarshalCBOR(bytes.NewReader(b)); err != nil {
return nil, xerrors.Errorf("failed to unmarshal PublishStorageDealsReturn: %w", err)
}

return &publishStorageDealsReturn3{retval}, nil
}

type publishStorageDealsReturn3 struct {
market3.PublishStorageDealsReturn
}

func (r *publishStorageDealsReturn3) IsDealValid(index uint64) (bool, error) {

// 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
}
27 changes: 27 additions & 0 deletions chain/actors/builtin/market/v4.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/filecoin-project/go-state-types/abi"
"github.com/ipfs/go-cid"
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors"

"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/types"
Expand Down Expand Up @@ -224,3 +225,29 @@ func fromV4DealProposal(v4 market4.DealProposal) DealProposal {
func (s *state4) GetState() interface{} {
return &s.State
}

var _ PublishStorageDealsReturn = (*publishStorageDealsReturn4)(nil)

func decodePublishStorageDealsReturn4(b []byte) (PublishStorageDealsReturn, error) {
var retval market4.PublishStorageDealsReturn
if err := retval.UnmarshalCBOR(bytes.NewReader(b)); err != nil {
return nil, xerrors.Errorf("failed to unmarshal PublishStorageDealsReturn: %w", err)
}

return &publishStorageDealsReturn4{retval}, nil
}

type publishStorageDealsReturn4 struct {
market4.PublishStorageDealsReturn
}

func (r *publishStorageDealsReturn4) IsDealValid(index uint64) (bool, error) {

// 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
}
27 changes: 27 additions & 0 deletions chain/actors/builtin/market/v5.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/filecoin-project/go-state-types/abi"
"github.com/ipfs/go-cid"
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors"

"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/types"
Expand Down Expand Up @@ -224,3 +225,29 @@ func fromV5DealProposal(v5 market5.DealProposal) DealProposal {
func (s *state5) GetState() interface{} {
return &s.State
}

var _ PublishStorageDealsReturn = (*publishStorageDealsReturn5)(nil)

func decodePublishStorageDealsReturn5(b []byte) (PublishStorageDealsReturn, error) {
var retval market5.PublishStorageDealsReturn
if err := retval.UnmarshalCBOR(bytes.NewReader(b)); err != nil {
return nil, xerrors.Errorf("failed to unmarshal PublishStorageDealsReturn: %w", err)
}

return &publishStorageDealsReturn5{retval}, nil
}

type publishStorageDealsReturn5 struct {
market5.PublishStorageDealsReturn
}

func (r *publishStorageDealsReturn5) IsDealValid(index uint64) (bool, error) {

// 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
}
26 changes: 26 additions & 0 deletions chain/actors/builtin/market/v6.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/filecoin-project/go-state-types/abi"
"github.com/ipfs/go-cid"
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors"

"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/types"
Expand Down Expand Up @@ -224,3 +225,28 @@ func fromV6DealProposal(v6 market6.DealProposal) DealProposal {
func (s *state6) GetState() interface{} {
return &s.State
}

var _ PublishStorageDealsReturn = (*publishStorageDealsReturn6)(nil)

func decodePublishStorageDealsReturn6(b []byte) (PublishStorageDealsReturn, error) {
var retval market6.PublishStorageDealsReturn
if err := retval.UnmarshalCBOR(bytes.NewReader(b)); err != nil {
return nil, xerrors.Errorf("failed to unmarshal PublishStorageDealsReturn: %w", err)
}

return &publishStorageDealsReturn6{retval}, nil
}

type publishStorageDealsReturn6 struct {
market6.PublishStorageDealsReturn
}

func (r *publishStorageDealsReturn6) IsDealValid(index uint64) (bool, error) {

return r.ValidDeals.IsSet(index)

}

func (r *publishStorageDealsReturn6) DealIDs() ([]abi.DealID, error) {
return r.IDs, nil
}
Loading