review fixes

This commit is contained in:
Geoff Stuart 2022-10-05 14:43:16 -04:00
parent 97b04b7f77
commit b5c5e6627e
41 changed files with 331 additions and 328 deletions

View File

@ -964,6 +964,11 @@ workflows:
suite: itest-paych_cli
target: "./itests/paych_cli_test.go"
- test:
name: test-itest-pending_deal_allocation_retrieval
suite: itest-pending_deal_allocation_retrieval
target: "./itests/pending_deal_allocation_retrieval_test.go"
- test:
name: test-itest-sdr_upgrade
suite: itest-sdr_upgrade

View File

@ -528,10 +528,10 @@ type FullNode interface {
StateMarketDeals(context.Context, types.TipSetKey) (map[string]*MarketDeal, error) //perm:read
// StateMarketStorageDeal returns information about the indicated deal
StateMarketStorageDeal(context.Context, abi.DealID, types.TipSetKey) (*MarketDeal, error) //perm:read
// StateGetDealAllocation returns the allocation ID for a given deal ID.
StateGetDealAllocation(ctx context.Context, dealId abi.DealID, tsk types.TipSetKey) (*verifregtypes.Allocation, error) //perm:read
// StateGetAllocation returns the allocation ID for a given address and allocation ID.
StateGetAllocation(ctx context.Context, addr address.Address, allocationId verifregtypes.AllocationId, tsk types.TipSetKey) (*verifregtypes.Allocation, error) //perm:read
// StateGetAllocationForPendingDeal returns the allocation for a given deal ID of a pending deal.
StateGetAllocationForPendingDeal(ctx context.Context, dealId abi.DealID, tsk types.TipSetKey) (*verifregtypes.Allocation, error) //perm:read
// StateGetAllocation returns the allocation for a given address and allocation ID.
StateGetAllocation(ctx context.Context, clientAddr address.Address, allocationId verifregtypes.AllocationId, tsk types.TipSetKey) (*verifregtypes.Allocation, error) //perm:read
// StateComputeDataCID computes DataCID from a set of on-chain deals
StateComputeDataCID(ctx context.Context, maddr address.Address, sectorType abi.RegisteredSealProof, deals []abi.DealID, tsk types.TipSetKey) (cid.Cid, error) //perm:read
// StateLookupID retrieves the ID address of the given address

View File

@ -2483,6 +2483,21 @@ func (mr *MockFullNodeMockRecorder) StateGetAllocation(arg0, arg1, arg2, arg3 in
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateGetAllocation", reflect.TypeOf((*MockFullNode)(nil).StateGetAllocation), arg0, arg1, arg2, arg3)
}
// StateGetAllocationForPendingDeal mocks base method.
func (m *MockFullNode) StateGetAllocationForPendingDeal(arg0 context.Context, arg1 abi.DealID, arg2 types.TipSetKey) (*verifreg.Allocation, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "StateGetAllocationForPendingDeal", arg0, arg1, arg2)
ret0, _ := ret[0].(*verifreg.Allocation)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// StateGetAllocationForPendingDeal indicates an expected call of StateGetAllocationForPendingDeal.
func (mr *MockFullNodeMockRecorder) StateGetAllocationForPendingDeal(arg0, arg1, arg2 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateGetAllocationForPendingDeal", reflect.TypeOf((*MockFullNode)(nil).StateGetAllocationForPendingDeal), arg0, arg1, arg2)
}
// StateGetBeaconEntry mocks base method.
func (m *MockFullNode) StateGetBeaconEntry(arg0 context.Context, arg1 abi.ChainEpoch) (*types.BeaconEntry, error) {
m.ctrl.T.Helper()
@ -2498,21 +2513,6 @@ func (mr *MockFullNodeMockRecorder) StateGetBeaconEntry(arg0, arg1 interface{})
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateGetBeaconEntry", reflect.TypeOf((*MockFullNode)(nil).StateGetBeaconEntry), arg0, arg1)
}
// StateGetDealAllocation mocks base method.
func (m *MockFullNode) StateGetDealAllocation(arg0 context.Context, arg1 abi.DealID, arg2 types.TipSetKey) (*verifreg.Allocation, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "StateGetDealAllocation", arg0, arg1, arg2)
ret0, _ := ret[0].(*verifreg.Allocation)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// StateGetDealAllocation indicates an expected call of StateGetDealAllocation.
func (mr *MockFullNodeMockRecorder) StateGetDealAllocation(arg0, arg1, arg2 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateGetDealAllocation", reflect.TypeOf((*MockFullNode)(nil).StateGetDealAllocation), arg0, arg1, arg2)
}
// StateGetNetworkParams mocks base method.
func (m *MockFullNode) StateGetNetworkParams(arg0 context.Context) (*api.NetworkParams, error) {
m.ctrl.T.Helper()

View File

@ -368,9 +368,9 @@ type FullNodeStruct struct {
StateGetAllocation func(p0 context.Context, p1 address.Address, p2 verifregtypes.AllocationId, p3 types.TipSetKey) (*verifregtypes.Allocation, error) `perm:"read"`
StateGetBeaconEntry func(p0 context.Context, p1 abi.ChainEpoch) (*types.BeaconEntry, error) `perm:"read"`
StateGetAllocationForPendingDeal func(p0 context.Context, p1 abi.DealID, p2 types.TipSetKey) (*verifregtypes.Allocation, error) `perm:"read"`
StateGetDealAllocation func(p0 context.Context, p1 abi.DealID, p2 types.TipSetKey) (*verifregtypes.Allocation, error) `perm:"read"`
StateGetBeaconEntry func(p0 context.Context, p1 abi.ChainEpoch) (*types.BeaconEntry, error) `perm:"read"`
StateGetNetworkParams func(p0 context.Context) (*NetworkParams, error) `perm:"read"`
@ -2608,6 +2608,17 @@ func (s *FullNodeStub) StateGetAllocation(p0 context.Context, p1 address.Address
return nil, ErrNotSupported
}
func (s *FullNodeStruct) StateGetAllocationForPendingDeal(p0 context.Context, p1 abi.DealID, p2 types.TipSetKey) (*verifregtypes.Allocation, error) {
if s.Internal.StateGetAllocationForPendingDeal == nil {
return nil, ErrNotSupported
}
return s.Internal.StateGetAllocationForPendingDeal(p0, p1, p2)
}
func (s *FullNodeStub) StateGetAllocationForPendingDeal(p0 context.Context, p1 abi.DealID, p2 types.TipSetKey) (*verifregtypes.Allocation, error) {
return nil, ErrNotSupported
}
func (s *FullNodeStruct) StateGetBeaconEntry(p0 context.Context, p1 abi.ChainEpoch) (*types.BeaconEntry, error) {
if s.Internal.StateGetBeaconEntry == nil {
return nil, ErrNotSupported
@ -2619,17 +2630,6 @@ func (s *FullNodeStub) StateGetBeaconEntry(p0 context.Context, p1 abi.ChainEpoch
return nil, ErrNotSupported
}
func (s *FullNodeStruct) StateGetDealAllocation(p0 context.Context, p1 abi.DealID, p2 types.TipSetKey) (*verifregtypes.Allocation, error) {
if s.Internal.StateGetDealAllocation == nil {
return nil, ErrNotSupported
}
return s.Internal.StateGetDealAllocation(p0, p1, p2)
}
func (s *FullNodeStub) StateGetDealAllocation(p0 context.Context, p1 abi.DealID, p2 types.TipSetKey) (*verifregtypes.Allocation, error) {
return nil, ErrNotSupported
}
func (s *FullNodeStruct) StateGetNetworkParams(p0 context.Context) (*NetworkParams, error) {
if s.Internal.StateGetNetworkParams == nil {
return nil, ErrNotSupported

View File

@ -532,10 +532,10 @@ type FullNode interface {
StateMarketDeals(context.Context, types.TipSetKey) (map[string]*api.MarketDeal, error) //perm:read
// StateMarketStorageDeal returns information about the indicated deal
StateMarketStorageDeal(context.Context, abi.DealID, types.TipSetKey) (*api.MarketDeal, error) //perm:read
// StateGetDealAllocation returns the allocation ID for a given deal ID.
StateGetDealAllocation(ctx context.Context, dealId abi.DealID, tsk types.TipSetKey) (*verifregtypes.Allocation, error)
// StateGetAllocation returns the allocation ID for a given address and allocation ID.
StateGetAllocation(ctx context.Context, addr address.Address, allocationId verifregtypes.AllocationId, tsk types.TipSetKey) (*verifregtypes.Allocation, error) //perm:read
// StateGetAllocationForPendingDeal returns the allocation for a given deal ID of a pending deal.
StateGetAllocationForPendingDeal(ctx context.Context, dealId abi.DealID, tsk types.TipSetKey) (*verifregtypes.Allocation, error)
// StateGetAllocation returns the allocation for a given address and allocation ID.
StateGetAllocation(ctx context.Context, clientAddr address.Address, allocationId verifregtypes.AllocationId, tsk types.TipSetKey) (*verifregtypes.Allocation, error) //perm:read
// StateLookupID retrieves the ID address of the given address
StateLookupID(context.Context, address.Address, types.TipSetKey) (address.Address, error) //perm:read
// StateAccountKey returns the public key address of the given ID address

View File

@ -280,7 +280,7 @@ type FullNodeStruct struct {
StateGetAllocation func(p0 context.Context, p1 address.Address, p2 verifregtypes.AllocationId, p3 types.TipSetKey) (*verifregtypes.Allocation, error) `perm:"read"`
StateGetDealAllocation func(p0 context.Context, p1 abi.DealID, p2 types.TipSetKey) (*verifregtypes.Allocation, error) ``
StateGetAllocationForPendingDeal func(p0 context.Context, p1 abi.DealID, p2 types.TipSetKey) (*verifregtypes.Allocation, error) ``
StateGetNetworkParams func(p0 context.Context) (*api.NetworkParams, error) `perm:"read"`
@ -1809,14 +1809,14 @@ func (s *FullNodeStub) StateGetAllocation(p0 context.Context, p1 address.Address
return nil, ErrNotSupported
}
func (s *FullNodeStruct) StateGetDealAllocation(p0 context.Context, p1 abi.DealID, p2 types.TipSetKey) (*verifregtypes.Allocation, error) {
if s.Internal.StateGetDealAllocation == nil {
func (s *FullNodeStruct) StateGetAllocationForPendingDeal(p0 context.Context, p1 abi.DealID, p2 types.TipSetKey) (*verifregtypes.Allocation, error) {
if s.Internal.StateGetAllocationForPendingDeal == nil {
return nil, ErrNotSupported
}
return s.Internal.StateGetDealAllocation(p0, p1, p2)
return s.Internal.StateGetAllocationForPendingDeal(p0, p1, p2)
}
func (s *FullNodeStub) StateGetDealAllocation(p0 context.Context, p1 abi.DealID, p2 types.TipSetKey) (*verifregtypes.Allocation, error) {
func (s *FullNodeStub) StateGetAllocationForPendingDeal(p0 context.Context, p1 abi.DealID, p2 types.TipSetKey) (*verifregtypes.Allocation, error) {
return nil, ErrNotSupported
}

View File

@ -2338,19 +2338,19 @@ func (mr *MockFullNodeMockRecorder) StateGetAllocation(arg0, arg1, arg2, arg3 in
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateGetAllocation", reflect.TypeOf((*MockFullNode)(nil).StateGetAllocation), arg0, arg1, arg2, arg3)
}
// StateGetDealAllocation mocks base method.
func (m *MockFullNode) StateGetDealAllocation(arg0 context.Context, arg1 abi.DealID, arg2 types.TipSetKey) (*verifreg.Allocation, error) {
// StateGetAllocationForPendingDeal mocks base method.
func (m *MockFullNode) StateGetAllocationForPendingDeal(arg0 context.Context, arg1 abi.DealID, arg2 types.TipSetKey) (*verifreg.Allocation, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "StateGetDealAllocation", arg0, arg1, arg2)
ret := m.ctrl.Call(m, "StateGetAllocationForPendingDeal", arg0, arg1, arg2)
ret0, _ := ret[0].(*verifreg.Allocation)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// StateGetDealAllocation indicates an expected call of StateGetDealAllocation.
func (mr *MockFullNodeMockRecorder) StateGetDealAllocation(arg0, arg1, arg2 interface{}) *gomock.Call {
// StateGetAllocationForPendingDeal indicates an expected call of StateGetAllocationForPendingDeal.
func (mr *MockFullNodeMockRecorder) StateGetAllocationForPendingDeal(arg0, arg1, arg2 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateGetDealAllocation", reflect.TypeOf((*MockFullNode)(nil).StateGetDealAllocation), arg0, arg1, arg2)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateGetAllocationForPendingDeal", reflect.TypeOf((*MockFullNode)(nil).StateGetAllocationForPendingDeal), arg0, arg1, arg2)
}
// StateGetNetworkParams mocks base method.

Binary file not shown.

View File

@ -86,7 +86,7 @@ type State interface {
) (weight, verifiedWeight abi.DealWeight, err error)
NextID() (abi.DealID, error)
GetState() interface{}
GetAllocationId(dealId abi.DealID) (verifregtypes.AllocationId, error)
GetAllocationIdForPendingDeal(dealId abi.DealID) (verifregtypes.AllocationId, error)
}
type BalanceTable interface {

View File

@ -127,7 +127,7 @@ type State interface {
) (weight, verifiedWeight abi.DealWeight, err error)
NextID() (abi.DealID, error)
GetState() interface{}
GetAllocationId(dealId abi.DealID) (verifregtypes.AllocationId, error)
GetAllocationIdForPendingDeal(dealId abi.DealID) (verifregtypes.AllocationId, error)
}
type BalanceTable interface {

View File

@ -366,7 +366,7 @@ func (r *publishStorageDealsReturn{{.v}}) DealIDs() ([]abi.DealID, error) {
return r.IDs, nil
}
func (s *state{{.v}}) GetAllocationId(dealId abi.DealID) (verifregtypes.AllocationId, error) {
func (s *state{{.v}}) GetAllocationIdForPendingDeal(dealId abi.DealID) (verifregtypes.AllocationId, error) {
{{if (le .v 8)}}
return 0, xerrors.Errorf("unsupported before actors v9")
{{else}}

View File

@ -302,7 +302,7 @@ func (r *publishStorageDealsReturn0) DealIDs() ([]abi.DealID, error) {
return r.IDs, nil
}
func (s *state0) GetAllocationId(dealId abi.DealID) (verifregtypes.AllocationId, error) {
func (s *state0) GetAllocationIdForPendingDeal(dealId abi.DealID) (verifregtypes.AllocationId, error) {
return 0, xerrors.Errorf("unsupported before actors v9")

View File

@ -302,7 +302,7 @@ func (r *publishStorageDealsReturn2) DealIDs() ([]abi.DealID, error) {
return r.IDs, nil
}
func (s *state2) GetAllocationId(dealId abi.DealID) (verifregtypes.AllocationId, error) {
func (s *state2) GetAllocationIdForPendingDeal(dealId abi.DealID) (verifregtypes.AllocationId, error) {
return 0, xerrors.Errorf("unsupported before actors v9")

View File

@ -297,7 +297,7 @@ func (r *publishStorageDealsReturn3) DealIDs() ([]abi.DealID, error) {
return r.IDs, nil
}
func (s *state3) GetAllocationId(dealId abi.DealID) (verifregtypes.AllocationId, error) {
func (s *state3) GetAllocationIdForPendingDeal(dealId abi.DealID) (verifregtypes.AllocationId, error) {
return 0, xerrors.Errorf("unsupported before actors v9")

View File

@ -297,7 +297,7 @@ func (r *publishStorageDealsReturn4) DealIDs() ([]abi.DealID, error) {
return r.IDs, nil
}
func (s *state4) GetAllocationId(dealId abi.DealID) (verifregtypes.AllocationId, error) {
func (s *state4) GetAllocationIdForPendingDeal(dealId abi.DealID) (verifregtypes.AllocationId, error) {
return 0, xerrors.Errorf("unsupported before actors v9")

View File

@ -297,7 +297,7 @@ func (r *publishStorageDealsReturn5) DealIDs() ([]abi.DealID, error) {
return r.IDs, nil
}
func (s *state5) GetAllocationId(dealId abi.DealID) (verifregtypes.AllocationId, error) {
func (s *state5) GetAllocationIdForPendingDeal(dealId abi.DealID) (verifregtypes.AllocationId, error) {
return 0, xerrors.Errorf("unsupported before actors v9")

View File

@ -315,7 +315,7 @@ func (r *publishStorageDealsReturn6) DealIDs() ([]abi.DealID, error) {
return r.IDs, nil
}
func (s *state6) GetAllocationId(dealId abi.DealID) (verifregtypes.AllocationId, error) {
func (s *state6) GetAllocationIdForPendingDeal(dealId abi.DealID) (verifregtypes.AllocationId, error) {
return 0, xerrors.Errorf("unsupported before actors v9")

View File

@ -315,7 +315,7 @@ func (r *publishStorageDealsReturn7) DealIDs() ([]abi.DealID, error) {
return r.IDs, nil
}
func (s *state7) GetAllocationId(dealId abi.DealID) (verifregtypes.AllocationId, error) {
func (s *state7) GetAllocationIdForPendingDeal(dealId abi.DealID) (verifregtypes.AllocationId, error) {
return 0, xerrors.Errorf("unsupported before actors v9")

View File

@ -332,7 +332,7 @@ func (r *publishStorageDealsReturn8) DealIDs() ([]abi.DealID, error) {
return r.IDs, nil
}
func (s *state8) GetAllocationId(dealId abi.DealID) (verifregtypes.AllocationId, error) {
func (s *state8) GetAllocationIdForPendingDeal(dealId abi.DealID) (verifregtypes.AllocationId, error) {
return 0, xerrors.Errorf("unsupported before actors v9")

View File

@ -328,7 +328,7 @@ func (r *publishStorageDealsReturn9) DealIDs() ([]abi.DealID, error) {
return r.IDs, nil
}
func (s *state9) GetAllocationId(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 {

View File

@ -73,6 +73,6 @@ type State interface {
RemoveDataCapProposalID(verifier address.Address, client address.Address) (bool, uint64, error)
ForEachVerifier(func(addr address.Address, dcap abi.StoragePower) error) error
ForEachClient(func(addr address.Address, dcap abi.StoragePower) error) error
GetAllocation(addr address.Address, allocationId verifregtypes.AllocationId) (*verifregtypes.Allocation, bool, error)
GetAllocation(clientIdAddr address.Address, allocationId verifregtypes.AllocationId) (*verifregtypes.Allocation, bool, error)
GetState() interface{}
}

View File

@ -116,10 +116,10 @@ func (s *state{{.v}}) GetState() interface{} {
return &s.State
}
func (s *state{{.v}}) GetAllocation(addr address.Address, allocationId verifreg9.AllocationId) (*verifreg9.Allocation, bool, error) {
func (s *state{{.v}}) GetAllocation(clientIdAddr address.Address, allocationId verifreg9.AllocationId) (*verifreg9.Allocation, bool, error) {
{{if (le .v 8)}}
return nil, false, xerrors.Errorf("unsupported in actors v{{.v}}")
{{else}}
return s.FindAllocation(s.store, addr, allocationId)
return s.FindAllocation(s.store, clientIdAddr, allocationId)
{{end}}
}

View File

@ -90,7 +90,7 @@ func (s *state0) GetState() interface{} {
return &s.State
}
func (s *state0) GetAllocation(addr address.Address, allocationId verifreg9.AllocationId) (*verifreg9.Allocation, bool, error) {
func (s *state0) GetAllocation(clientIdAddr address.Address, allocationId verifreg9.AllocationId) (*verifreg9.Allocation, bool, error) {
return nil, false, xerrors.Errorf("unsupported in actors v0")

View File

@ -90,7 +90,7 @@ func (s *state2) GetState() interface{} {
return &s.State
}
func (s *state2) GetAllocation(addr address.Address, allocationId verifreg9.AllocationId) (*verifreg9.Allocation, bool, error) {
func (s *state2) GetAllocation(clientIdAddr address.Address, allocationId verifreg9.AllocationId) (*verifreg9.Allocation, bool, error) {
return nil, false, xerrors.Errorf("unsupported in actors v2")

View File

@ -91,7 +91,7 @@ func (s *state3) GetState() interface{} {
return &s.State
}
func (s *state3) GetAllocation(addr address.Address, allocationId verifreg9.AllocationId) (*verifreg9.Allocation, bool, error) {
func (s *state3) GetAllocation(clientIdAddr address.Address, allocationId verifreg9.AllocationId) (*verifreg9.Allocation, bool, error) {
return nil, false, xerrors.Errorf("unsupported in actors v3")

View File

@ -91,7 +91,7 @@ func (s *state4) GetState() interface{} {
return &s.State
}
func (s *state4) GetAllocation(addr address.Address, allocationId verifreg9.AllocationId) (*verifreg9.Allocation, bool, error) {
func (s *state4) GetAllocation(clientIdAddr address.Address, allocationId verifreg9.AllocationId) (*verifreg9.Allocation, bool, error) {
return nil, false, xerrors.Errorf("unsupported in actors v4")

View File

@ -91,7 +91,7 @@ func (s *state5) GetState() interface{} {
return &s.State
}
func (s *state5) GetAllocation(addr address.Address, allocationId verifreg9.AllocationId) (*verifreg9.Allocation, bool, error) {
func (s *state5) GetAllocation(clientIdAddr address.Address, allocationId verifreg9.AllocationId) (*verifreg9.Allocation, bool, error) {
return nil, false, xerrors.Errorf("unsupported in actors v5")

View File

@ -91,7 +91,7 @@ func (s *state6) GetState() interface{} {
return &s.State
}
func (s *state6) GetAllocation(addr address.Address, allocationId verifreg9.AllocationId) (*verifreg9.Allocation, bool, error) {
func (s *state6) GetAllocation(clientIdAddr address.Address, allocationId verifreg9.AllocationId) (*verifreg9.Allocation, bool, error) {
return nil, false, xerrors.Errorf("unsupported in actors v6")

View File

@ -90,7 +90,7 @@ func (s *state7) GetState() interface{} {
return &s.State
}
func (s *state7) GetAllocation(addr address.Address, allocationId verifreg9.AllocationId) (*verifreg9.Allocation, bool, error) {
func (s *state7) GetAllocation(clientIdAddr address.Address, allocationId verifreg9.AllocationId) (*verifreg9.Allocation, bool, error) {
return nil, false, xerrors.Errorf("unsupported in actors v7")

View File

@ -90,7 +90,7 @@ func (s *state8) GetState() interface{} {
return &s.State
}
func (s *state8) GetAllocation(addr address.Address, allocationId verifreg9.AllocationId) (*verifreg9.Allocation, bool, error) {
func (s *state8) GetAllocation(clientIdAddr address.Address, allocationId verifreg9.AllocationId) (*verifreg9.Allocation, bool, error) {
return nil, false, xerrors.Errorf("unsupported in actors v8")

View File

@ -90,8 +90,8 @@ func (s *state9) GetState() interface{} {
return &s.State
}
func (s *state9) GetAllocation(addr address.Address, allocationId verifreg9.AllocationId) (*verifreg9.Allocation, bool, error) {
func (s *state9) GetAllocation(clientIdAddr address.Address, allocationId verifreg9.AllocationId) (*verifreg9.Allocation, bool, error) {
return s.FindAllocation(s.store, addr, allocationId)
return s.FindAllocation(s.store, clientIdAddr, allocationId)
}

View File

@ -115,6 +115,6 @@ type State interface {
RemoveDataCapProposalID(verifier address.Address, client address.Address) (bool, uint64, error)
ForEachVerifier(func(addr address.Address, dcap abi.StoragePower) error) error
ForEachClient(func(addr address.Address, dcap abi.StoragePower) error) error
GetAllocation(addr address.Address, allocationId verifregtypes.AllocationId) (*verifregtypes.Allocation, bool, error)
GetAllocation(clientIdAddr address.Address, allocationId verifregtypes.AllocationId) (*verifregtypes.Allocation, bool, error)
GetState() interface{}
}

View File

@ -9,6 +9,7 @@ import (
"github.com/filecoin-project/go-address"
actorstypes "github.com/filecoin-project/go-state-types/actors"
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/go-state-types/builtin"
"github.com/filecoin-project/specs-actors/actors/util/adt"
bstore "github.com/filecoin-project/lotus/blockstore"
@ -20,7 +21,6 @@ import (
var GovernorId address.Address
func init() {
idk, err := address.NewFromString("t06")
if err != nil {
panic(err)
@ -31,19 +31,19 @@ func init() {
func SetupDatacapActor(ctx context.Context, bs bstore.Blockstore, av actorstypes.Version) (*types.Actor, error) {
cst := cbor.NewCborStore(bs)
vst, err := datacap.MakeState(adt.WrapStore(ctx, cbor.NewCborStore(bs)), av, GovernorId, 3) // TODO make into variable
dst, err := datacap.MakeState(adt.WrapStore(ctx, cbor.NewCborStore(bs)), av, GovernorId, builtin.DefaultTokenActorBitwidth)
if err != nil {
return nil, err
}
statecid, err := cst.Put(ctx, vst.GetState())
statecid, err := cst.Put(ctx, dst.GetState())
if err != nil {
return nil, err
}
actcid, ok := actors.GetActorCodeID(av, actors.DatacapKey)
if !ok {
return nil, xerrors.Errorf("failed to get verifreg actor code ID for actors version %d", av)
return nil, xerrors.Errorf("failed to get datacap actor code ID for actors version %d", av)
}
act := &types.Actor{

View File

@ -169,7 +169,7 @@
* [StateDecodeParams](#StateDecodeParams)
* [StateGetActor](#StateGetActor)
* [StateGetAllocation](#StateGetAllocation)
* [StateGetDealAllocation](#StateGetDealAllocation)
* [StateGetAllocationForPendingDeal](#StateGetAllocationForPendingDeal)
* [StateGetNetworkParams](#StateGetNetworkParams)
* [StateGetRandomnessFromBeacon](#StateGetRandomnessFromBeacon)
* [StateGetRandomnessFromTickets](#StateGetRandomnessFromTickets)
@ -5245,7 +5245,7 @@ Response:
```
### StateGetAllocation
StateGetAllocation returns the allocation ID for a given address and allocation ID.
StateGetAllocation returns the allocation for a given address and allocation ID.
Perms: read
@ -5281,8 +5281,8 @@ Response:
}
```
### StateGetDealAllocation
StateGetDealAllocation returns the allocation ID for a given deal ID.
### StateGetAllocationForPendingDeal
StateGetAllocationForPendingDeal returns the allocation for a given deal ID of a pending deal.
Perms:

View File

@ -179,8 +179,8 @@
* [StateEncodeParams](#StateEncodeParams)
* [StateGetActor](#StateGetActor)
* [StateGetAllocation](#StateGetAllocation)
* [StateGetAllocationForPendingDeal](#StateGetAllocationForPendingDeal)
* [StateGetBeaconEntry](#StateGetBeaconEntry)
* [StateGetDealAllocation](#StateGetDealAllocation)
* [StateGetNetworkParams](#StateGetNetworkParams)
* [StateGetRandomnessFromBeacon](#StateGetRandomnessFromBeacon)
* [StateGetRandomnessFromTickets](#StateGetRandomnessFromTickets)
@ -5728,7 +5728,7 @@ Response:
```
### StateGetAllocation
StateGetAllocation returns the allocation ID for a given address and allocation ID.
StateGetAllocation returns the allocation for a given address and allocation ID.
Perms: read
@ -5764,6 +5764,42 @@ Response:
}
```
### StateGetAllocationForPendingDeal
StateGetAllocationForPendingDeal returns the allocation for a given deal ID of a pending deal.
Perms: read
Inputs:
```json
[
5432,
[
{
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
{
"/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve"
}
]
]
```
Response:
```json
{
"Client": 1000,
"Provider": 1000,
"Data": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
"Size": 1032,
"TermMin": 10101,
"TermMax": 10101,
"Expiration": 10101
}
```
### StateGetBeaconEntry
StateGetBeaconEntry returns the beacon entry for the given filecoin epoch. If
the entry has not yet been produced, the call will block until the entry
@ -5787,42 +5823,6 @@ Response:
}
```
### StateGetDealAllocation
StateGetDealAllocation returns the allocation ID for a given deal ID.
Perms: read
Inputs:
```json
[
5432,
[
{
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
{
"/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve"
}
]
]
```
Response:
```json
{
"Client": 1000,
"Provider": 1000,
"Data": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
"Size": 1032,
"TermMin": 10101,
"TermMax": 10101,
"Expiration": 10101
}
```
### StateGetNetworkParams
StateGetNetworkParams return current network params

2
go.mod
View File

@ -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.1.13-0.20221004175601-1427aec8869f
github.com/filecoin-project/go-state-types v0.1.13-0.20221005183518-065d9b6b758b
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

4
go.sum
View File

@ -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.1.13-0.20221004175601-1427aec8869f h1:UKVkUqu7aMXr07HpBqCvC1J8R0lTFX7rK6+92XUs10g=
github.com/filecoin-project/go-state-types v0.1.13-0.20221004175601-1427aec8869f/go.mod h1:+HCZifUV+e8TlQkgll22Ucuiq8OrVJkK+4Kh4u75iiw=
github.com/filecoin-project/go-state-types v0.1.13-0.20221005183518-065d9b6b758b h1:xHgXHL/FBDBYGslrF52G2E/eyJwm4aFpnrK7e2bzSqU=
github.com/filecoin-project/go-state-types v0.1.13-0.20221005183518-065d9b6b758b/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=

View File

@ -2,9 +2,7 @@
package itests
import (
"bytes"
"context"
"fmt"
"path/filepath"
"testing"
"time"
@ -15,22 +13,9 @@ import (
commp "github.com/filecoin-project/go-fil-commp-hashhash"
"github.com/filecoin-project/go-fil-markets/storagemarket"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/go-state-types/builtin"
markettypes "github.com/filecoin-project/go-state-types/builtin/v9/market"
verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg"
"github.com/filecoin-project/go-state-types/crypto"
"github.com/filecoin-project/go-state-types/exitcode"
lapi "github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/builtin/market"
"github.com/filecoin-project/lotus/chain/actors/builtin/verifreg"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/wallet/key"
"github.com/filecoin-project/lotus/itests/kit"
"github.com/filecoin-project/lotus/node/impl"
)
func TestOfflineDealFlow(t *testing.T) {
@ -120,178 +105,3 @@ func TestOfflineDealFlow(t *testing.T) {
t.Run("fastretrieval", func(t *testing.T) { runTest(t, true, 0) })
t.Run("fastretrieval", func(t *testing.T) { runTest(t, true, 1024) })
}
func TestGetAllocationFromDealId(t *testing.T) {
ctx := context.Background()
rootKey, err := key.GenerateKey(types.KTSecp256k1)
require.NoError(t, err)
verifierKey, err := key.GenerateKey(types.KTSecp256k1)
require.NoError(t, err)
verifiedClientKey, err := key.GenerateKey(types.KTBLS)
require.NoError(t, err)
bal, err := types.ParseFIL("100fil")
require.NoError(t, err)
node, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(),
kit.RootVerifier(rootKey, abi.NewTokenAmount(bal.Int64())),
kit.Account(verifierKey, abi.NewTokenAmount(bal.Int64())), // assign some balance to the verifier so they can send an AddClient message.
kit.Account(verifiedClientKey, abi.NewTokenAmount(bal.Int64())),
)
ens.InterconnectAll().BeginMining(250 * time.Millisecond)
api := node.FullNode.(*impl.FullNodeAPI)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
// get VRH
//stm: @CHAIN_STATE_VERIFIED_REGISTRY_ROOT_KEY_001
vrh, err := api.StateVerifiedRegistryRootKey(ctx, types.TipSetKey{})
fmt.Println(vrh.String())
require.NoError(t, err)
// import the root key.
rootAddr, err := api.WalletImport(ctx, &rootKey.KeyInfo)
require.NoError(t, err)
// import the verifier's key.
verifierAddr, err := api.WalletImport(ctx, &verifierKey.KeyInfo)
require.NoError(t, err)
// import the verified client's key.
verifiedClientAddr, err := api.WalletImport(ctx, &verifiedClientKey.KeyInfo)
require.NoError(t, err)
params, err := actors.SerializeParams(&verifregtypes.AddVerifierParams{Address: verifierAddr, Allowance: big.NewInt(100000000000)})
require.NoError(t, err)
msg := &types.Message{
From: rootAddr,
To: verifreg.Address,
Method: verifreg.Methods.AddVerifier,
Params: params,
Value: big.Zero(),
}
sm, err := api.MpoolPushMessage(ctx, msg, nil)
require.NoError(t, err, "AddVerifier failed")
//stm: @CHAIN_STATE_WAIT_MSG_001
res, err := api.StateWaitMsg(ctx, sm.Cid(), 1, lapi.LookbackNoLimit, true)
require.NoError(t, err)
require.EqualValues(t, 0, res.Receipt.ExitCode)
// assign datacap to a client
datacap := big.NewInt(10000)
params, err = actors.SerializeParams(&verifregtypes.AddVerifiedClientParams{Address: verifiedClientAddr, Allowance: datacap})
require.NoError(t, err)
msg = &types.Message{
From: verifierAddr,
To: verifreg.Address,
Method: verifreg.Methods.AddVerifiedClient,
Params: params,
Value: big.Zero(),
}
sm, err = api.MpoolPushMessage(ctx, msg, nil)
require.NoError(t, err)
//stm: @CHAIN_STATE_WAIT_MSG_001
res, err = api.StateWaitMsg(ctx, sm.Cid(), 1, lapi.LookbackNoLimit, true)
require.NoError(t, err)
require.EqualValues(t, 0, res.Receipt.ExitCode)
// check datacap balance
//stm: @CHAIN_STATE_VERIFIED_CLIENT_STATUS_001
dcap, err := api.StateVerifiedClientStatus(ctx, verifiedClientAddr, types.EmptyTSK)
require.NoError(t, err)
if !dcap.Equals(datacap) {
t.Fatal("")
}
// Create a random file and import on the client.
importedFile, _ := node.CreateImportFile(ctx, 1, 200)
// Get the piece size and commP
rootCid := importedFile.Root
pieceInfo, err := node.ClientDealPieceCID(ctx, rootCid)
require.NoError(t, err)
t.Log("FILE CID:", rootCid)
label, err := markettypes.NewLabelFromString("")
require.NoError(t, err)
dealProposal := markettypes.DealProposal{
PieceCID: pieceInfo.PieceCID,
PieceSize: pieceInfo.PieceSize,
Client: verifiedClientAddr,
Provider: miner.ActorAddr,
Label: label,
StartEpoch: abi.ChainEpoch(1000_000),
EndEpoch: abi.ChainEpoch(2000_000),
StoragePricePerEpoch: big.Zero(),
ProviderCollateral: big.Zero(),
ClientCollateral: big.Zero(),
VerifiedDeal: true,
}
serializedProposal := new(bytes.Buffer)
err = dealProposal.MarshalCBOR(serializedProposal)
require.NoError(t, err)
sig, err := api.WalletSign(ctx, verifiedClientAddr, serializedProposal.Bytes())
publishDealParams := markettypes.PublishStorageDealsParams{
Deals: []markettypes.ClientDealProposal{{
Proposal: dealProposal,
ClientSignature: crypto.Signature{
Type: crypto.SigTypeBLS,
Data: sig.Data,
},
}},
}
serializedParams := new(bytes.Buffer)
require.NoError(t, publishDealParams.MarshalCBOR(serializedParams))
m, err := node.MpoolPushMessage(ctx, &types.Message{
To: builtin.StorageMarketActorAddr,
From: miner.OwnerKey.Address,
Value: types.FromFil(0),
Method: builtin.MethodsMarket.PublishStorageDeals,
Params: serializedParams.Bytes(),
}, nil)
require.NoError(t, err)
r, err := node.StateWaitMsg(ctx, m.Cid(), 2, lapi.LookbackNoLimit, true)
require.NoError(t, err)
require.Equal(t, exitcode.Ok, r.Receipt.ExitCode)
ret, err := market.DecodePublishStorageDealsReturn(r.Receipt.Return, build.TestNetworkVersion)
require.NoError(t, err)
valid, _, err := ret.IsDealValid(0)
require.NoError(t, err)
require.True(t, valid)
dealIds, err := ret.DealIDs()
require.NoError(t, err)
dealInfo, err := api.StateMarketStorageDeal(ctx, dealIds[0], types.EmptyTSK)
require.NoError(t, err)
require.Equal(t, verifregtypes.AllocationId(0), dealInfo.State.VerifiedClaim) // Allocation in State should not be set yet, because it's in the allocation map
allocation, err := api.StateGetDealAllocation(ctx, dealIds[0], types.EmptyTSK)
require.NoError(t, err)
require.Equal(t, dealProposal.PieceCID, allocation.Data)
// Just another way of getting the allocation if we don't have the deal ID
allocation, err = api.StateGetAllocation(ctx, verifiedClientAddr, 3, types.EmptyTSK)
require.NoError(t, err)
require.Equal(t, dealProposal.PieceCID, allocation.Data)
}

View File

@ -0,0 +1,197 @@
// stm: #integration
package itests
import (
"bytes"
"context"
"fmt"
"testing"
"time"
"github.com/stretchr/testify/require"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/go-state-types/builtin"
markettypes "github.com/filecoin-project/go-state-types/builtin/v9/market"
verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg"
"github.com/filecoin-project/go-state-types/crypto"
"github.com/filecoin-project/go-state-types/exitcode"
lapi "github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/builtin/market"
"github.com/filecoin-project/lotus/chain/actors/builtin/verifreg"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/wallet/key"
"github.com/filecoin-project/lotus/itests/kit"
"github.com/filecoin-project/lotus/node/impl"
)
func TestGetAllocationForPendingDeal(t *testing.T) {
ctx := context.Background()
rootKey, err := key.GenerateKey(types.KTSecp256k1)
require.NoError(t, err)
verifierKey, err := key.GenerateKey(types.KTSecp256k1)
require.NoError(t, err)
verifiedClientKey, err := key.GenerateKey(types.KTBLS)
require.NoError(t, err)
bal, err := types.ParseFIL("100fil")
require.NoError(t, err)
node, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(),
kit.RootVerifier(rootKey, abi.NewTokenAmount(bal.Int64())),
kit.Account(verifierKey, abi.NewTokenAmount(bal.Int64())), // assign some balance to the verifier so they can send an AddClient message.
kit.Account(verifiedClientKey, abi.NewTokenAmount(bal.Int64())),
)
ens.InterconnectAll().BeginMining(250 * time.Millisecond)
api := node.FullNode.(*impl.FullNodeAPI)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
// get VRH
//stm: @CHAIN_STATE_VERIFIED_REGISTRY_ROOT_KEY_001
vrh, err := api.StateVerifiedRegistryRootKey(ctx, types.TipSetKey{})
fmt.Println(vrh.String())
require.NoError(t, err)
// import the root key.
rootAddr, err := api.WalletImport(ctx, &rootKey.KeyInfo)
require.NoError(t, err)
// import the verifier's key.
verifierAddr, err := api.WalletImport(ctx, &verifierKey.KeyInfo)
require.NoError(t, err)
// import the verified client's key.
verifiedClientAddr, err := api.WalletImport(ctx, &verifiedClientKey.KeyInfo)
require.NoError(t, err)
params, err := actors.SerializeParams(&verifregtypes.AddVerifierParams{Address: verifierAddr, Allowance: big.NewInt(100000000000)})
require.NoError(t, err)
msg := &types.Message{
From: rootAddr,
To: verifreg.Address,
Method: verifreg.Methods.AddVerifier,
Params: params,
Value: big.Zero(),
}
sm, err := api.MpoolPushMessage(ctx, msg, nil)
require.NoError(t, err, "AddVerifier failed")
//stm: @CHAIN_STATE_WAIT_MSG_001
res, err := api.StateWaitMsg(ctx, sm.Cid(), 1, lapi.LookbackNoLimit, true)
require.NoError(t, err)
require.EqualValues(t, 0, res.Receipt.ExitCode)
// assign datacap to a client
datacap := big.NewInt(10000)
params, err = actors.SerializeParams(&verifregtypes.AddVerifiedClientParams{Address: verifiedClientAddr, Allowance: datacap})
require.NoError(t, err)
msg = &types.Message{
From: verifierAddr,
To: verifreg.Address,
Method: verifreg.Methods.AddVerifiedClient,
Params: params,
Value: big.Zero(),
}
sm, err = api.MpoolPushMessage(ctx, msg, nil)
require.NoError(t, err)
//stm: @CHAIN_STATE_WAIT_MSG_001
res, err = api.StateWaitMsg(ctx, sm.Cid(), 1, lapi.LookbackNoLimit, true)
require.NoError(t, err)
require.EqualValues(t, 0, res.Receipt.ExitCode)
// check datacap balance
//stm: @CHAIN_STATE_VERIFIED_CLIENT_STATUS_001
dcap, err := api.StateVerifiedClientStatus(ctx, verifiedClientAddr, types.EmptyTSK)
require.NoError(t, err)
require.Equal(t, *dcap, datacap)
// Create a random file and import on the client.
importedFile, _ := node.CreateImportFile(ctx, 1, 200)
// Get the piece size and commP
rootCid := importedFile.Root
pieceInfo, err := node.ClientDealPieceCID(ctx, rootCid)
require.NoError(t, err)
t.Log("FILE CID:", rootCid)
label, err := markettypes.NewLabelFromString("")
require.NoError(t, err)
dealProposal := markettypes.DealProposal{
PieceCID: pieceInfo.PieceCID,
PieceSize: pieceInfo.PieceSize,
Client: verifiedClientAddr,
Provider: miner.ActorAddr,
Label: label,
StartEpoch: abi.ChainEpoch(1000_000),
EndEpoch: abi.ChainEpoch(2000_000),
StoragePricePerEpoch: big.Zero(),
ProviderCollateral: big.Zero(),
ClientCollateral: big.Zero(),
VerifiedDeal: true,
}
serializedProposal := new(bytes.Buffer)
err = dealProposal.MarshalCBOR(serializedProposal)
require.NoError(t, err)
sig, err := api.WalletSign(ctx, verifiedClientAddr, serializedProposal.Bytes())
publishDealParams := markettypes.PublishStorageDealsParams{
Deals: []markettypes.ClientDealProposal{{
Proposal: dealProposal,
ClientSignature: crypto.Signature{
Type: crypto.SigTypeBLS,
Data: sig.Data,
},
}},
}
serializedParams := new(bytes.Buffer)
require.NoError(t, publishDealParams.MarshalCBOR(serializedParams))
m, err := node.MpoolPushMessage(ctx, &types.Message{
To: builtin.StorageMarketActorAddr,
From: miner.OwnerKey.Address,
Value: types.FromFil(0),
Method: builtin.MethodsMarket.PublishStorageDeals,
Params: serializedParams.Bytes(),
}, nil)
require.NoError(t, err)
r, err := node.StateWaitMsg(ctx, m.Cid(), 2, lapi.LookbackNoLimit, true)
require.NoError(t, err)
require.Equal(t, exitcode.Ok, r.Receipt.ExitCode)
ret, err := market.DecodePublishStorageDealsReturn(r.Receipt.Return, build.TestNetworkVersion)
require.NoError(t, err)
valid, _, err := ret.IsDealValid(0)
require.NoError(t, err)
require.True(t, valid)
dealIds, err := ret.DealIDs()
require.NoError(t, err)
dealInfo, err := api.StateMarketStorageDeal(ctx, dealIds[0], types.EmptyTSK)
require.NoError(t, err)
require.Equal(t, verifregtypes.AllocationId(0), dealInfo.State.VerifiedClaim) // Allocation in State should not be set yet, because it's in the allocation map
allocation, err := api.StateGetAllocationForPendingDeal(ctx, dealIds[0], types.EmptyTSK)
require.NoError(t, err)
require.Equal(t, dealProposal.PieceCID, allocation.Data)
}

View File

@ -123,10 +123,7 @@ func TestVerifiedClientTopUp(t *testing.T) {
//stm: @CHAIN_STATE_VERIFIED_CLIENT_STATUS_001
dcap, err := api.StateVerifiedClientStatus(ctx, verifiedClientAddr, types.EmptyTSK)
require.NoError(t, err)
if !dcap.Equals(datacap) {
t.Fatal("")
}
require.Equal(t, *dcap, datacap)
// try to assign datacap to the same client should fail for actor v4 and below
params, err = actors.SerializeParams(&verifregst.AddVerifiedClientParams{Address: verifiedClientAddr, Allowance: datacap})
@ -280,10 +277,7 @@ func TestRemoveDataCap(t *testing.T) {
//stm: @CHAIN_STATE_VERIFIED_CLIENT_STATUS_001
dcap, err := api.StateVerifiedClientStatus(ctx, verifiedClientAddr, types.EmptyTSK)
require.NoError(t, err)
if !dcap.Equals(datacap) {
t.Fatal("unexpected datacap")
}
require.Equal(t, *dcap, datacap)
// helper to create removedatacap message
makeRemoveDatacapMsg := func(removeDatacap big.Int, proposalID uint64) *types.Message {
@ -354,10 +348,7 @@ func TestRemoveDataCap(t *testing.T) {
//stm: @CHAIN_STATE_VERIFIED_CLIENT_STATUS_001
dcap, err = api.StateVerifiedClientStatus(ctx, verifiedClientAddr, types.EmptyTSK)
require.NoError(t, err)
if !dcap.Equals(big.Sub(datacap, removeDatacap)) {
t.Fatal("unexpected datacap")
}
require.Equal(t, *dcap, big.Sub(datacap, removeDatacap))
// now take away the second half!

View File

@ -771,7 +771,7 @@ func (m *StateModule) StateMarketStorageDeal(ctx context.Context, dealId abi.Dea
return stmgr.GetStorageDeal(ctx, m.StateManager, dealId, ts)
}
func (a *StateAPI) StateGetDealAllocation(ctx context.Context, dealId abi.DealID, tsk types.TipSetKey) (*verifregtypes.Allocation, error) {
func (a *StateAPI) StateGetAllocationForPendingDeal(ctx context.Context, dealId abi.DealID, tsk types.TipSetKey) (*verifregtypes.Allocation, error) {
ts, err := a.Chain.GetTipSetFromKey(ctx, tsk)
if err != nil {
return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err)
@ -782,7 +782,7 @@ func (a *StateAPI) StateGetDealAllocation(ctx context.Context, dealId abi.DealID
return nil, err
}
allocationId, err := st.GetAllocationId(dealId)
allocationId, err := st.GetAllocationIdForPendingDeal(dealId)
if err != nil {
return nil, err
}
@ -795,8 +795,8 @@ func (a *StateAPI) StateGetDealAllocation(ctx context.Context, dealId abi.DealID
return a.StateGetAllocation(ctx, dealState.Proposal.Client, allocationId, tsk)
}
func (a *StateAPI) StateGetAllocation(ctx context.Context, addr address.Address, allocationId verifregtypes.AllocationId, tsk types.TipSetKey) (*verifregtypes.Allocation, error) {
idAddr, err := a.StateLookupID(ctx, addr, tsk)
func (a *StateAPI) StateGetAllocation(ctx context.Context, clientAddr address.Address, allocationId verifregtypes.AllocationId, tsk types.TipSetKey) (*verifregtypes.Allocation, error) {
idAddr, err := a.StateLookupID(ctx, clientAddr, tsk)
if err != nil {
return nil, err
}