From 6e36386bcc90f610489b299894bef457fdc7b4fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 11 Oct 2022 18:31:19 +0200 Subject: [PATCH] use NoAllocationID instead of nil AllocationId --- chain/actors/builtin/market/actor.go.template | 2 +- chain/actors/builtin/market/market.go | 2 +- chain/actors/builtin/market/state.go.template | 13 ++++++------- chain/actors/builtin/market/v0.go | 4 ++-- chain/actors/builtin/market/v2.go | 4 ++-- chain/actors/builtin/market/v3.go | 4 ++-- chain/actors/builtin/market/v4.go | 4 ++-- chain/actors/builtin/market/v5.go | 4 ++-- chain/actors/builtin/market/v6.go | 4 ++-- chain/actors/builtin/market/v7.go | 4 ++-- chain/actors/builtin/market/v8.go | 4 ++-- chain/actors/builtin/market/v9.go | 11 +++++------ go.mod | 2 +- go.sum | 4 ++-- node/impl/full/state.go | 4 ++-- 15 files changed, 34 insertions(+), 36 deletions(-) diff --git a/chain/actors/builtin/market/actor.go.template b/chain/actors/builtin/market/actor.go.template index bd05bfcc6a9..fa0622ff022 100644 --- a/chain/actors/builtin/market/actor.go.template +++ b/chain/actors/builtin/market/actor.go.template @@ -86,7 +86,7 @@ type State interface { ) (weight, verifiedWeight abi.DealWeight, err error) NextID() (abi.DealID, error) GetState() interface{} - GetAllocationIdForPendingDeal(dealId abi.DealID) (*verifregtypes.AllocationId, error) + GetAllocationIdForPendingDeal(dealId abi.DealID) (verifregtypes.AllocationId, error) } type BalanceTable interface { diff --git a/chain/actors/builtin/market/market.go b/chain/actors/builtin/market/market.go index 2479964bd2c..0e095d28202 100644 --- a/chain/actors/builtin/market/market.go +++ b/chain/actors/builtin/market/market.go @@ -127,7 +127,7 @@ type State interface { ) (weight, verifiedWeight abi.DealWeight, err error) NextID() (abi.DealID, error) GetState() interface{} - GetAllocationIdForPendingDeal(dealId abi.DealID) (*verifregtypes.AllocationId, error) + GetAllocationIdForPendingDeal(dealId abi.DealID) (verifregtypes.AllocationId, error) } type BalanceTable interface { diff --git a/chain/actors/builtin/market/state.go.template b/chain/actors/builtin/market/state.go.template index 0684377e908..50abdeb6bfb 100644 --- a/chain/actors/builtin/market/state.go.template +++ b/chain/actors/builtin/market/state.go.template @@ -366,25 +366,24 @@ func (r *publishStorageDealsReturn{{.v}}) DealIDs() ([]abi.DealID, error) { return r.IDs, nil } -func (s *state{{.v}}) GetAllocationIdForPendingDeal(dealId abi.DealID) (*verifregtypes.AllocationId, error) { +func (s *state{{.v}}) GetAllocationIdForPendingDeal(dealId abi.DealID) (verifregtypes.AllocationId, error) { {{if (le .v 8)}} - return nil, xerrors.Errorf("unsupported before actors v9") + return verifregtypes.NoAllocationID, xerrors.Errorf("unsupported before actors v9") {{else}} allocations, err := adt9.AsMap(s.store, s.PendingDealAllocationIds, builtin.DefaultHamtBitwidth) if err != nil { - return nil, xerrors.Errorf("failed to load allocation id for %d: %w", dealId, err) + return verifregtypes.NoAllocationID, xerrors.Errorf("failed to load allocation id for %d: %w", dealId, err) } var allocationId cbg.CborInt found, err := allocations.Get(abi.UIntKey(uint64(dealId)), &allocationId) if err != nil { - return nil, xerrors.Errorf("failed to load allocation id for %d: %w", dealId, err) + return verifregtypes.NoAllocationID, xerrors.Errorf("failed to load allocation id for %d: %w", dealId, err) } if !found { - return nil, nil + return verifregtypes.NoAllocationID, nil } - aid := verifregtypes.AllocationId(allocationId) - return &aid, nil + return verifregtypes.AllocationId(allocationId), nil {{end}} } diff --git a/chain/actors/builtin/market/v0.go b/chain/actors/builtin/market/v0.go index 15c9530cd7a..aa68049bbeb 100644 --- a/chain/actors/builtin/market/v0.go +++ b/chain/actors/builtin/market/v0.go @@ -302,8 +302,8 @@ func (r *publishStorageDealsReturn0) DealIDs() ([]abi.DealID, error) { return r.IDs, nil } -func (s *state0) GetAllocationIdForPendingDeal(dealId abi.DealID) (*verifregtypes.AllocationId, error) { +func (s *state0) GetAllocationIdForPendingDeal(dealId abi.DealID) (verifregtypes.AllocationId, error) { - return nil, xerrors.Errorf("unsupported before actors v9") + return verifregtypes.NoAllocationID, xerrors.Errorf("unsupported before actors v9") } diff --git a/chain/actors/builtin/market/v2.go b/chain/actors/builtin/market/v2.go index c6b43386593..777a17cd054 100644 --- a/chain/actors/builtin/market/v2.go +++ b/chain/actors/builtin/market/v2.go @@ -302,8 +302,8 @@ func (r *publishStorageDealsReturn2) DealIDs() ([]abi.DealID, error) { return r.IDs, nil } -func (s *state2) GetAllocationIdForPendingDeal(dealId abi.DealID) (*verifregtypes.AllocationId, error) { +func (s *state2) GetAllocationIdForPendingDeal(dealId abi.DealID) (verifregtypes.AllocationId, error) { - return nil, xerrors.Errorf("unsupported before actors v9") + return verifregtypes.NoAllocationID, xerrors.Errorf("unsupported before actors v9") } diff --git a/chain/actors/builtin/market/v3.go b/chain/actors/builtin/market/v3.go index ca6f341911b..5ca09fdfbd1 100644 --- a/chain/actors/builtin/market/v3.go +++ b/chain/actors/builtin/market/v3.go @@ -297,8 +297,8 @@ func (r *publishStorageDealsReturn3) DealIDs() ([]abi.DealID, error) { return r.IDs, nil } -func (s *state3) GetAllocationIdForPendingDeal(dealId abi.DealID) (*verifregtypes.AllocationId, error) { +func (s *state3) GetAllocationIdForPendingDeal(dealId abi.DealID) (verifregtypes.AllocationId, error) { - return nil, xerrors.Errorf("unsupported before actors v9") + return verifregtypes.NoAllocationID, xerrors.Errorf("unsupported before actors v9") } diff --git a/chain/actors/builtin/market/v4.go b/chain/actors/builtin/market/v4.go index 3c17ab8143d..23422ec31a3 100644 --- a/chain/actors/builtin/market/v4.go +++ b/chain/actors/builtin/market/v4.go @@ -297,8 +297,8 @@ func (r *publishStorageDealsReturn4) DealIDs() ([]abi.DealID, error) { return r.IDs, nil } -func (s *state4) GetAllocationIdForPendingDeal(dealId abi.DealID) (*verifregtypes.AllocationId, error) { +func (s *state4) GetAllocationIdForPendingDeal(dealId abi.DealID) (verifregtypes.AllocationId, error) { - return nil, xerrors.Errorf("unsupported before actors v9") + return verifregtypes.NoAllocationID, xerrors.Errorf("unsupported before actors v9") } diff --git a/chain/actors/builtin/market/v5.go b/chain/actors/builtin/market/v5.go index f7d006fdd1d..8e8833c37f3 100644 --- a/chain/actors/builtin/market/v5.go +++ b/chain/actors/builtin/market/v5.go @@ -297,8 +297,8 @@ func (r *publishStorageDealsReturn5) DealIDs() ([]abi.DealID, error) { return r.IDs, nil } -func (s *state5) GetAllocationIdForPendingDeal(dealId abi.DealID) (*verifregtypes.AllocationId, error) { +func (s *state5) GetAllocationIdForPendingDeal(dealId abi.DealID) (verifregtypes.AllocationId, error) { - return nil, xerrors.Errorf("unsupported before actors v9") + return verifregtypes.NoAllocationID, xerrors.Errorf("unsupported before actors v9") } diff --git a/chain/actors/builtin/market/v6.go b/chain/actors/builtin/market/v6.go index 517c1ff87d5..d86f73108c8 100644 --- a/chain/actors/builtin/market/v6.go +++ b/chain/actors/builtin/market/v6.go @@ -315,8 +315,8 @@ func (r *publishStorageDealsReturn6) DealIDs() ([]abi.DealID, error) { return r.IDs, nil } -func (s *state6) GetAllocationIdForPendingDeal(dealId abi.DealID) (*verifregtypes.AllocationId, error) { +func (s *state6) GetAllocationIdForPendingDeal(dealId abi.DealID) (verifregtypes.AllocationId, error) { - return nil, xerrors.Errorf("unsupported before actors v9") + return verifregtypes.NoAllocationID, xerrors.Errorf("unsupported before actors v9") } diff --git a/chain/actors/builtin/market/v7.go b/chain/actors/builtin/market/v7.go index 62a39814c1e..5f6547e3f5a 100644 --- a/chain/actors/builtin/market/v7.go +++ b/chain/actors/builtin/market/v7.go @@ -315,8 +315,8 @@ func (r *publishStorageDealsReturn7) DealIDs() ([]abi.DealID, error) { return r.IDs, nil } -func (s *state7) GetAllocationIdForPendingDeal(dealId abi.DealID) (*verifregtypes.AllocationId, error) { +func (s *state7) GetAllocationIdForPendingDeal(dealId abi.DealID) (verifregtypes.AllocationId, error) { - return nil, xerrors.Errorf("unsupported before actors v9") + return verifregtypes.NoAllocationID, xerrors.Errorf("unsupported before actors v9") } diff --git a/chain/actors/builtin/market/v8.go b/chain/actors/builtin/market/v8.go index 22fead2eed3..5f3b690bbd0 100644 --- a/chain/actors/builtin/market/v8.go +++ b/chain/actors/builtin/market/v8.go @@ -332,8 +332,8 @@ func (r *publishStorageDealsReturn8) DealIDs() ([]abi.DealID, error) { return r.IDs, nil } -func (s *state8) GetAllocationIdForPendingDeal(dealId abi.DealID) (*verifregtypes.AllocationId, error) { +func (s *state8) GetAllocationIdForPendingDeal(dealId abi.DealID) (verifregtypes.AllocationId, error) { - return nil, xerrors.Errorf("unsupported before actors v9") + return verifregtypes.NoAllocationID, xerrors.Errorf("unsupported before actors v9") } diff --git a/chain/actors/builtin/market/v9.go b/chain/actors/builtin/market/v9.go index f1b06a5f754..9fed45ae8bc 100644 --- a/chain/actors/builtin/market/v9.go +++ b/chain/actors/builtin/market/v9.go @@ -328,23 +328,22 @@ func (r *publishStorageDealsReturn9) DealIDs() ([]abi.DealID, error) { return r.IDs, nil } -func (s *state9) GetAllocationIdForPendingDeal(dealId abi.DealID) (*verifregtypes.AllocationId, error) { +func (s *state9) GetAllocationIdForPendingDeal(dealId abi.DealID) (verifregtypes.AllocationId, error) { allocations, err := adt9.AsMap(s.store, s.PendingDealAllocationIds, builtin.DefaultHamtBitwidth) if err != nil { - return nil, xerrors.Errorf("failed to load allocation id for %d: %w", dealId, err) + return verifregtypes.NoAllocationID, xerrors.Errorf("failed to load allocation id for %d: %w", dealId, err) } var allocationId cbg.CborInt found, err := allocations.Get(abi.UIntKey(uint64(dealId)), &allocationId) if err != nil { - return nil, xerrors.Errorf("failed to load allocation id for %d: %w", dealId, err) + return verifregtypes.NoAllocationID, xerrors.Errorf("failed to load allocation id for %d: %w", dealId, err) } if !found { - return nil, nil + return verifregtypes.NoAllocationID, nil } - aid := verifregtypes.AllocationId(allocationId) - return &aid, nil + return verifregtypes.AllocationId(allocationId), nil } diff --git a/go.mod b/go.mod index f3c073c70a6..b70ff949ee6 100644 --- a/go.mod +++ b/go.mod @@ -42,7 +42,7 @@ require ( github.com/filecoin-project/go-legs v0.4.4 github.com/filecoin-project/go-padreader v0.0.1 github.com/filecoin-project/go-paramfetch v0.0.4 - github.com/filecoin-project/go-state-types v0.9.0-rc1 + github.com/filecoin-project/go-state-types v0.9.0-rc2 github.com/filecoin-project/go-statemachine v1.0.2 github.com/filecoin-project/go-statestore v0.2.0 github.com/filecoin-project/go-storedcounter v0.1.0 diff --git a/go.sum b/go.sum index d41f757150c..91d74610685 100644 --- a/go.sum +++ b/go.sum @@ -343,8 +343,8 @@ github.com/filecoin-project/go-state-types v0.1.0/go.mod h1:ezYnPf0bNkTsDibL/psS github.com/filecoin-project/go-state-types v0.1.6/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q= github.com/filecoin-project/go-state-types v0.1.8/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q= github.com/filecoin-project/go-state-types v0.1.10/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q= -github.com/filecoin-project/go-state-types v0.9.0-rc1 h1:cK6OzKP11aIFt0fbor/lqvrzEBegbMGHnSr9LJN/r4g= -github.com/filecoin-project/go-state-types v0.9.0-rc1/go.mod h1:+HCZifUV+e8TlQkgll22Ucuiq8OrVJkK+4Kh4u75iiw= +github.com/filecoin-project/go-state-types v0.9.0-rc2 h1:HtSxHUEwAtpnhV/77/ugnUt9lwvTTcQ7PRV+5iTAcUw= +github.com/filecoin-project/go-state-types v0.9.0-rc2/go.mod h1:+HCZifUV+e8TlQkgll22Ucuiq8OrVJkK+4Kh4u75iiw= github.com/filecoin-project/go-statemachine v0.0.0-20200925024713-05bd7c71fbfe/go.mod h1:FGwQgZAt2Gh5mjlwJUlVB62JeYdo+if0xWxSEfBD9ig= github.com/filecoin-project/go-statemachine v1.0.2 h1:421SSWBk8GIoCoWYYTE/d+qCWccgmRH0uXotXRDjUbc= github.com/filecoin-project/go-statemachine v1.0.2/go.mod h1:jZdXXiHa61n4NmgWFG4w8tnqgvZVHYbJ3yW7+y8bF54= diff --git a/node/impl/full/state.go b/node/impl/full/state.go index b8d0414e507..9ef351719fc 100644 --- a/node/impl/full/state.go +++ b/node/impl/full/state.go @@ -786,7 +786,7 @@ func (a *StateAPI) StateGetAllocationForPendingDeal(ctx context.Context, dealId if err != nil { return nil, err } - if allocationId == nil { + if allocationId == verifregtypes.NoAllocationID { return nil, nil } @@ -795,7 +795,7 @@ func (a *StateAPI) StateGetAllocationForPendingDeal(ctx context.Context, dealId return nil, err } - return a.StateGetAllocation(ctx, dealState.Proposal.Client, *allocationId, tsk) + return a.StateGetAllocation(ctx, dealState.Proposal.Client, allocationId, tsk) } func (a *StateAPI) StateGetAllocation(ctx context.Context, clientAddr address.Address, allocationId verifregtypes.AllocationId, tsk types.TipSetKey) (*verifregtypes.Allocation, error) {