diff --git a/api/api_full.go b/api/api_full.go index eadf3d48a..1ec1c22be 100644 --- a/api/api_full.go +++ b/api/api_full.go @@ -532,6 +532,12 @@ type FullNode interface { 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 + // StateGetAllocations returns the all the allocations for a given client. + StateGetAllocations(ctx context.Context, clientAddr address.Address, tsk types.TipSetKey) (map[verifregtypes.AllocationId]verifregtypes.Allocation, error) //perm:read + // StateGetClaim returns the claim for a given address and claim ID. + StateGetClaim(ctx context.Context, providerAddr address.Address, claimId verifregtypes.ClaimId, tsk types.TipSetKey) (*verifregtypes.Claim, error) //perm:read + // StateGetClaims returns the all the claims for a given provider. + StateGetClaims(ctx context.Context, providerAddr address.Address, tsk types.TipSetKey) (map[verifregtypes.ClaimId]verifregtypes.Claim, 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 diff --git a/api/docgen/docgen.go b/api/docgen/docgen.go index 8d1abb1e3..5bddef2ec 100644 --- a/api/docgen/docgen.go +++ b/api/docgen/docgen.go @@ -142,6 +142,11 @@ func init() { allocationId := verifreg.AllocationId(0) addExample(allocationId) addExample(&allocationId) + addExample(map[verifreg.AllocationId]verifreg.Allocation{}) + claimId := verifreg.ClaimId(0) + addExample(claimId) + addExample(&claimId) + addExample(map[verifreg.ClaimId]verifreg.Claim{}) addExample(map[string]int{"name": 42}) addExample(map[string]time.Time{"name": time.Unix(1615243938, 0).UTC()}) addExample(&types.ExecutionTrace{ diff --git a/api/mocks/mock_full.go b/api/mocks/mock_full.go index 594ec5684..18c260061 100644 --- a/api/mocks/mock_full.go +++ b/api/mocks/mock_full.go @@ -2498,6 +2498,21 @@ func (mr *MockFullNodeMockRecorder) StateGetAllocationForPendingDeal(arg0, arg1, return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateGetAllocationForPendingDeal", reflect.TypeOf((*MockFullNode)(nil).StateGetAllocationForPendingDeal), arg0, arg1, arg2) } +// StateGetAllocations mocks base method. +func (m *MockFullNode) StateGetAllocations(arg0 context.Context, arg1 address.Address, arg2 types.TipSetKey) (map[verifreg.AllocationId]verifreg.Allocation, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StateGetAllocations", arg0, arg1, arg2) + ret0, _ := ret[0].(map[verifreg.AllocationId]verifreg.Allocation) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// StateGetAllocations indicates an expected call of StateGetAllocations. +func (mr *MockFullNodeMockRecorder) StateGetAllocations(arg0, arg1, arg2 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateGetAllocations", reflect.TypeOf((*MockFullNode)(nil).StateGetAllocations), arg0, arg1, arg2) +} + // StateGetBeaconEntry mocks base method. func (m *MockFullNode) StateGetBeaconEntry(arg0 context.Context, arg1 abi.ChainEpoch) (*types.BeaconEntry, error) { m.ctrl.T.Helper() @@ -2513,6 +2528,36 @@ func (mr *MockFullNodeMockRecorder) StateGetBeaconEntry(arg0, arg1 interface{}) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateGetBeaconEntry", reflect.TypeOf((*MockFullNode)(nil).StateGetBeaconEntry), arg0, arg1) } +// StateGetClaim mocks base method. +func (m *MockFullNode) StateGetClaim(arg0 context.Context, arg1 address.Address, arg2 verifreg.ClaimId, arg3 types.TipSetKey) (*verifreg.Claim, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StateGetClaim", arg0, arg1, arg2, arg3) + ret0, _ := ret[0].(*verifreg.Claim) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// StateGetClaim indicates an expected call of StateGetClaim. +func (mr *MockFullNodeMockRecorder) StateGetClaim(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateGetClaim", reflect.TypeOf((*MockFullNode)(nil).StateGetClaim), arg0, arg1, arg2, arg3) +} + +// StateGetClaims mocks base method. +func (m *MockFullNode) StateGetClaims(arg0 context.Context, arg1 address.Address, arg2 types.TipSetKey) (map[verifreg.ClaimId]verifreg.Claim, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StateGetClaims", arg0, arg1, arg2) + ret0, _ := ret[0].(map[verifreg.ClaimId]verifreg.Claim) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// StateGetClaims indicates an expected call of StateGetClaims. +func (mr *MockFullNodeMockRecorder) StateGetClaims(arg0, arg1, arg2 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateGetClaims", reflect.TypeOf((*MockFullNode)(nil).StateGetClaims), arg0, arg1, arg2) +} + // StateGetNetworkParams mocks base method. func (m *MockFullNode) StateGetNetworkParams(arg0 context.Context) (*api.NetworkParams, error) { m.ctrl.T.Helper() diff --git a/api/proxy_gen.go b/api/proxy_gen.go index 329ad62f5..b466d6336 100644 --- a/api/proxy_gen.go +++ b/api/proxy_gen.go @@ -370,8 +370,14 @@ type FullNodeStruct struct { StateGetAllocationForPendingDeal func(p0 context.Context, p1 abi.DealID, p2 types.TipSetKey) (*verifregtypes.Allocation, error) `perm:"read"` + StateGetAllocations func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (map[verifregtypes.AllocationId]verifregtypes.Allocation, error) `perm:"read"` + StateGetBeaconEntry func(p0 context.Context, p1 abi.ChainEpoch) (*types.BeaconEntry, error) `perm:"read"` + StateGetClaim func(p0 context.Context, p1 address.Address, p2 verifregtypes.ClaimId, p3 types.TipSetKey) (*verifregtypes.Claim, error) `perm:"read"` + + StateGetClaims func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (map[verifregtypes.ClaimId]verifregtypes.Claim, error) `perm:"read"` + StateGetNetworkParams func(p0 context.Context) (*NetworkParams, error) `perm:"read"` StateGetRandomnessFromBeacon func(p0 context.Context, p1 crypto.DomainSeparationTag, p2 abi.ChainEpoch, p3 []byte, p4 types.TipSetKey) (abi.Randomness, error) `perm:"read"` @@ -2619,6 +2625,17 @@ func (s *FullNodeStub) StateGetAllocationForPendingDeal(p0 context.Context, p1 a return nil, ErrNotSupported } +func (s *FullNodeStruct) StateGetAllocations(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (map[verifregtypes.AllocationId]verifregtypes.Allocation, error) { + if s.Internal.StateGetAllocations == nil { + return *new(map[verifregtypes.AllocationId]verifregtypes.Allocation), ErrNotSupported + } + return s.Internal.StateGetAllocations(p0, p1, p2) +} + +func (s *FullNodeStub) StateGetAllocations(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (map[verifregtypes.AllocationId]verifregtypes.Allocation, error) { + return *new(map[verifregtypes.AllocationId]verifregtypes.Allocation), ErrNotSupported +} + func (s *FullNodeStruct) StateGetBeaconEntry(p0 context.Context, p1 abi.ChainEpoch) (*types.BeaconEntry, error) { if s.Internal.StateGetBeaconEntry == nil { return nil, ErrNotSupported @@ -2630,6 +2647,28 @@ func (s *FullNodeStub) StateGetBeaconEntry(p0 context.Context, p1 abi.ChainEpoch return nil, ErrNotSupported } +func (s *FullNodeStruct) StateGetClaim(p0 context.Context, p1 address.Address, p2 verifregtypes.ClaimId, p3 types.TipSetKey) (*verifregtypes.Claim, error) { + if s.Internal.StateGetClaim == nil { + return nil, ErrNotSupported + } + return s.Internal.StateGetClaim(p0, p1, p2, p3) +} + +func (s *FullNodeStub) StateGetClaim(p0 context.Context, p1 address.Address, p2 verifregtypes.ClaimId, p3 types.TipSetKey) (*verifregtypes.Claim, error) { + return nil, ErrNotSupported +} + +func (s *FullNodeStruct) StateGetClaims(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (map[verifregtypes.ClaimId]verifregtypes.Claim, error) { + if s.Internal.StateGetClaims == nil { + return *new(map[verifregtypes.ClaimId]verifregtypes.Claim), ErrNotSupported + } + return s.Internal.StateGetClaims(p0, p1, p2) +} + +func (s *FullNodeStub) StateGetClaims(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (map[verifregtypes.ClaimId]verifregtypes.Claim, error) { + return *new(map[verifregtypes.ClaimId]verifregtypes.Claim), ErrNotSupported +} + func (s *FullNodeStruct) StateGetNetworkParams(p0 context.Context) (*NetworkParams, error) { if s.Internal.StateGetNetworkParams == nil { return nil, ErrNotSupported diff --git a/api/v0api/full.go b/api/v0api/full.go index 474d93298..4cbf18a82 100644 --- a/api/v0api/full.go +++ b/api/v0api/full.go @@ -536,6 +536,12 @@ type FullNode interface { 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 + // StateGetAllocations returns the all the allocations for a given client. + StateGetAllocations(ctx context.Context, clientAddr address.Address, tsk types.TipSetKey) (map[verifregtypes.AllocationId]verifregtypes.Allocation, error) //perm:read + // StateGetClaim returns the claim for a given address and claim ID. + StateGetClaim(ctx context.Context, providerAddr address.Address, claimId verifregtypes.ClaimId, tsk types.TipSetKey) (*verifregtypes.Claim, error) //perm:read + // StateGetClaims returns the all the claims for a given provider. + StateGetClaims(ctx context.Context, providerAddr address.Address, tsk types.TipSetKey) (map[verifregtypes.ClaimId]verifregtypes.Claim, 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 diff --git a/api/v0api/proxy_gen.go b/api/v0api/proxy_gen.go index 1941fe832..e35cc3e3c 100644 --- a/api/v0api/proxy_gen.go +++ b/api/v0api/proxy_gen.go @@ -282,6 +282,12 @@ type FullNodeStruct struct { StateGetAllocationForPendingDeal func(p0 context.Context, p1 abi.DealID, p2 types.TipSetKey) (*verifregtypes.Allocation, error) `` + StateGetAllocations func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (map[verifregtypes.AllocationId]verifregtypes.Allocation, error) `perm:"read"` + + StateGetClaim func(p0 context.Context, p1 address.Address, p2 verifregtypes.ClaimId, p3 types.TipSetKey) (*verifregtypes.Claim, error) `perm:"read"` + + StateGetClaims func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (map[verifregtypes.ClaimId]verifregtypes.Claim, error) `perm:"read"` + StateGetNetworkParams func(p0 context.Context) (*api.NetworkParams, error) `perm:"read"` StateGetRandomnessFromBeacon func(p0 context.Context, p1 crypto.DomainSeparationTag, p2 abi.ChainEpoch, p3 []byte, p4 types.TipSetKey) (abi.Randomness, error) `perm:"read"` @@ -1820,6 +1826,39 @@ func (s *FullNodeStub) StateGetAllocationForPendingDeal(p0 context.Context, p1 a return nil, ErrNotSupported } +func (s *FullNodeStruct) StateGetAllocations(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (map[verifregtypes.AllocationId]verifregtypes.Allocation, error) { + if s.Internal.StateGetAllocations == nil { + return *new(map[verifregtypes.AllocationId]verifregtypes.Allocation), ErrNotSupported + } + return s.Internal.StateGetAllocations(p0, p1, p2) +} + +func (s *FullNodeStub) StateGetAllocations(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (map[verifregtypes.AllocationId]verifregtypes.Allocation, error) { + return *new(map[verifregtypes.AllocationId]verifregtypes.Allocation), ErrNotSupported +} + +func (s *FullNodeStruct) StateGetClaim(p0 context.Context, p1 address.Address, p2 verifregtypes.ClaimId, p3 types.TipSetKey) (*verifregtypes.Claim, error) { + if s.Internal.StateGetClaim == nil { + return nil, ErrNotSupported + } + return s.Internal.StateGetClaim(p0, p1, p2, p3) +} + +func (s *FullNodeStub) StateGetClaim(p0 context.Context, p1 address.Address, p2 verifregtypes.ClaimId, p3 types.TipSetKey) (*verifregtypes.Claim, error) { + return nil, ErrNotSupported +} + +func (s *FullNodeStruct) StateGetClaims(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (map[verifregtypes.ClaimId]verifregtypes.Claim, error) { + if s.Internal.StateGetClaims == nil { + return *new(map[verifregtypes.ClaimId]verifregtypes.Claim), ErrNotSupported + } + return s.Internal.StateGetClaims(p0, p1, p2) +} + +func (s *FullNodeStub) StateGetClaims(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (map[verifregtypes.ClaimId]verifregtypes.Claim, error) { + return *new(map[verifregtypes.ClaimId]verifregtypes.Claim), ErrNotSupported +} + func (s *FullNodeStruct) StateGetNetworkParams(p0 context.Context) (*api.NetworkParams, error) { if s.Internal.StateGetNetworkParams == nil { return nil, ErrNotSupported diff --git a/api/v0api/v0mocks/mock_full.go b/api/v0api/v0mocks/mock_full.go index 5fe2bd34b..85ef2ddb0 100644 --- a/api/v0api/v0mocks/mock_full.go +++ b/api/v0api/v0mocks/mock_full.go @@ -2353,6 +2353,51 @@ func (mr *MockFullNodeMockRecorder) StateGetAllocationForPendingDeal(arg0, arg1, return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateGetAllocationForPendingDeal", reflect.TypeOf((*MockFullNode)(nil).StateGetAllocationForPendingDeal), arg0, arg1, arg2) } +// StateGetAllocations mocks base method. +func (m *MockFullNode) StateGetAllocations(arg0 context.Context, arg1 address.Address, arg2 types.TipSetKey) (map[verifreg.AllocationId]verifreg.Allocation, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StateGetAllocations", arg0, arg1, arg2) + ret0, _ := ret[0].(map[verifreg.AllocationId]verifreg.Allocation) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// StateGetAllocations indicates an expected call of StateGetAllocations. +func (mr *MockFullNodeMockRecorder) StateGetAllocations(arg0, arg1, arg2 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateGetAllocations", reflect.TypeOf((*MockFullNode)(nil).StateGetAllocations), arg0, arg1, arg2) +} + +// StateGetClaim mocks base method. +func (m *MockFullNode) StateGetClaim(arg0 context.Context, arg1 address.Address, arg2 verifreg.ClaimId, arg3 types.TipSetKey) (*verifreg.Claim, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StateGetClaim", arg0, arg1, arg2, arg3) + ret0, _ := ret[0].(*verifreg.Claim) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// StateGetClaim indicates an expected call of StateGetClaim. +func (mr *MockFullNodeMockRecorder) StateGetClaim(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateGetClaim", reflect.TypeOf((*MockFullNode)(nil).StateGetClaim), arg0, arg1, arg2, arg3) +} + +// StateGetClaims mocks base method. +func (m *MockFullNode) StateGetClaims(arg0 context.Context, arg1 address.Address, arg2 types.TipSetKey) (map[verifreg.ClaimId]verifreg.Claim, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StateGetClaims", arg0, arg1, arg2) + ret0, _ := ret[0].(map[verifreg.ClaimId]verifreg.Claim) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// StateGetClaims indicates an expected call of StateGetClaims. +func (mr *MockFullNodeMockRecorder) StateGetClaims(arg0, arg1, arg2 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateGetClaims", reflect.TypeOf((*MockFullNode)(nil).StateGetClaims), arg0, arg1, arg2) +} + // StateGetNetworkParams mocks base method. func (m *MockFullNode) StateGetNetworkParams(arg0 context.Context) (*api.NetworkParams, error) { m.ctrl.T.Helper() diff --git a/build/openrpc/full.json.gz b/build/openrpc/full.json.gz index 4b943a63e..aec7b5f31 100644 Binary files a/build/openrpc/full.json.gz and b/build/openrpc/full.json.gz differ diff --git a/build/openrpc/gateway.json.gz b/build/openrpc/gateway.json.gz index 25dd1108f..ee68ff9ee 100644 Binary files a/build/openrpc/gateway.json.gz and b/build/openrpc/gateway.json.gz differ diff --git a/build/openrpc/miner.json.gz b/build/openrpc/miner.json.gz index 93056b90d..58103c25d 100644 Binary files a/build/openrpc/miner.json.gz and b/build/openrpc/miner.json.gz differ diff --git a/build/openrpc/worker.json.gz b/build/openrpc/worker.json.gz index 37483bd2c..364ce19d9 100644 Binary files a/build/openrpc/worker.json.gz and b/build/openrpc/worker.json.gz differ diff --git a/chain/actors/builtin/verifreg/actor.go.template b/chain/actors/builtin/verifreg/actor.go.template index 3c6557ac3..5c7715e3d 100644 --- a/chain/actors/builtin/verifreg/actor.go.template +++ b/chain/actors/builtin/verifreg/actor.go.template @@ -74,5 +74,8 @@ type State interface { ForEachVerifier(func(addr address.Address, dcap abi.StoragePower) error) error ForEachClient(func(addr address.Address, dcap abi.StoragePower) error) error GetAllocation(clientIdAddr address.Address, allocationId verifregtypes.AllocationId) (*verifregtypes.Allocation, bool, error) + GetAllocations(clientIdAddr address.Address) (map[verifregtypes.AllocationId]verifregtypes.Allocation, error) + GetClaim(providerIdAddr address.Address, claimId verifregtypes.ClaimId) (*verifregtypes.Claim, bool, error) + GetClaims(providerIdAddr address.Address) (map[verifregtypes.ClaimId]verifregtypes.Claim, error) GetState() interface{} } diff --git a/chain/actors/builtin/verifreg/state.go.template b/chain/actors/builtin/verifreg/state.go.template index 8ab7b4ffd..cc3c2a781 100644 --- a/chain/actors/builtin/verifreg/state.go.template +++ b/chain/actors/builtin/verifreg/state.go.template @@ -122,4 +122,28 @@ func (s *state{{.v}}) GetAllocation(clientIdAddr address.Address, allocationId v {{else}} return s.FindAllocation(s.store, clientIdAddr, allocationId) {{end}} -} \ No newline at end of file +} + +func (s *state{{.v}}) GetAllocations(clientIdAddr address.Address) (map[verifreg9.AllocationId]verifreg9.Allocation, error) { +{{if (le .v 8)}} + return nil, xerrors.Errorf("unsupported in actors v{{.v}}") +{{else}} + return s.LoadAllocationsToMap(s.store, clientIdAddr) +{{end}} +} + +func (s *state{{.v}}) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*verifreg9.Claim, bool, error) { +{{if (le .v 8)}} + return nil, false, xerrors.Errorf("unsupported in actors v{{.v}}") +{{else}} + return s.FindClaim(s.store, providerIdAddr, claimId) +{{end}} +} + +func (s *state{{.v}}) GetClaims(providerIdAddr address.Address) (map[verifreg9.ClaimId]verifreg9.Claim, error) { +{{if (le .v 8)}} + return nil, xerrors.Errorf("unsupported in actors v{{.v}}") +{{else}} + return s.LoadClaimsToMap(s.store, providerIdAddr) +{{end}} +} diff --git a/chain/actors/builtin/verifreg/v0.go b/chain/actors/builtin/verifreg/v0.go index b812b24bc..debe32125 100644 --- a/chain/actors/builtin/verifreg/v0.go +++ b/chain/actors/builtin/verifreg/v0.go @@ -95,3 +95,21 @@ func (s *state0) GetAllocation(clientIdAddr address.Address, allocationId verifr return nil, false, xerrors.Errorf("unsupported in actors v0") } + +func (s *state0) GetAllocations(clientIdAddr address.Address) (map[verifreg9.AllocationId]verifreg9.Allocation, error) { + + return nil, xerrors.Errorf("unsupported in actors v0") + +} + +func (s *state0) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*verifreg9.Claim, bool, error) { + + return nil, false, xerrors.Errorf("unsupported in actors v0") + +} + +func (s *state0) GetClaims(providerIdAddr address.Address) (map[verifreg9.ClaimId]verifreg9.Claim, error) { + + return nil, xerrors.Errorf("unsupported in actors v0") + +} diff --git a/chain/actors/builtin/verifreg/v2.go b/chain/actors/builtin/verifreg/v2.go index 2e5f0d953..a6f07eea2 100644 --- a/chain/actors/builtin/verifreg/v2.go +++ b/chain/actors/builtin/verifreg/v2.go @@ -95,3 +95,21 @@ func (s *state2) GetAllocation(clientIdAddr address.Address, allocationId verifr return nil, false, xerrors.Errorf("unsupported in actors v2") } + +func (s *state2) GetAllocations(clientIdAddr address.Address) (map[verifreg9.AllocationId]verifreg9.Allocation, error) { + + return nil, xerrors.Errorf("unsupported in actors v2") + +} + +func (s *state2) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*verifreg9.Claim, bool, error) { + + return nil, false, xerrors.Errorf("unsupported in actors v2") + +} + +func (s *state2) GetClaims(providerIdAddr address.Address) (map[verifreg9.ClaimId]verifreg9.Claim, error) { + + return nil, xerrors.Errorf("unsupported in actors v2") + +} diff --git a/chain/actors/builtin/verifreg/v3.go b/chain/actors/builtin/verifreg/v3.go index 96d78711f..11e56d8ae 100644 --- a/chain/actors/builtin/verifreg/v3.go +++ b/chain/actors/builtin/verifreg/v3.go @@ -96,3 +96,21 @@ func (s *state3) GetAllocation(clientIdAddr address.Address, allocationId verifr return nil, false, xerrors.Errorf("unsupported in actors v3") } + +func (s *state3) GetAllocations(clientIdAddr address.Address) (map[verifreg9.AllocationId]verifreg9.Allocation, error) { + + return nil, xerrors.Errorf("unsupported in actors v3") + +} + +func (s *state3) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*verifreg9.Claim, bool, error) { + + return nil, false, xerrors.Errorf("unsupported in actors v3") + +} + +func (s *state3) GetClaims(providerIdAddr address.Address) (map[verifreg9.ClaimId]verifreg9.Claim, error) { + + return nil, xerrors.Errorf("unsupported in actors v3") + +} diff --git a/chain/actors/builtin/verifreg/v4.go b/chain/actors/builtin/verifreg/v4.go index 8154bb409..da51e78b8 100644 --- a/chain/actors/builtin/verifreg/v4.go +++ b/chain/actors/builtin/verifreg/v4.go @@ -96,3 +96,21 @@ func (s *state4) GetAllocation(clientIdAddr address.Address, allocationId verifr return nil, false, xerrors.Errorf("unsupported in actors v4") } + +func (s *state4) GetAllocations(clientIdAddr address.Address) (map[verifreg9.AllocationId]verifreg9.Allocation, error) { + + return nil, xerrors.Errorf("unsupported in actors v4") + +} + +func (s *state4) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*verifreg9.Claim, bool, error) { + + return nil, false, xerrors.Errorf("unsupported in actors v4") + +} + +func (s *state4) GetClaims(providerIdAddr address.Address) (map[verifreg9.ClaimId]verifreg9.Claim, error) { + + return nil, xerrors.Errorf("unsupported in actors v4") + +} diff --git a/chain/actors/builtin/verifreg/v5.go b/chain/actors/builtin/verifreg/v5.go index 0a193b31c..08f8ad706 100644 --- a/chain/actors/builtin/verifreg/v5.go +++ b/chain/actors/builtin/verifreg/v5.go @@ -96,3 +96,21 @@ func (s *state5) GetAllocation(clientIdAddr address.Address, allocationId verifr return nil, false, xerrors.Errorf("unsupported in actors v5") } + +func (s *state5) GetAllocations(clientIdAddr address.Address) (map[verifreg9.AllocationId]verifreg9.Allocation, error) { + + return nil, xerrors.Errorf("unsupported in actors v5") + +} + +func (s *state5) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*verifreg9.Claim, bool, error) { + + return nil, false, xerrors.Errorf("unsupported in actors v5") + +} + +func (s *state5) GetClaims(providerIdAddr address.Address) (map[verifreg9.ClaimId]verifreg9.Claim, error) { + + return nil, xerrors.Errorf("unsupported in actors v5") + +} diff --git a/chain/actors/builtin/verifreg/v6.go b/chain/actors/builtin/verifreg/v6.go index 2df747b7d..8e6fc3603 100644 --- a/chain/actors/builtin/verifreg/v6.go +++ b/chain/actors/builtin/verifreg/v6.go @@ -96,3 +96,21 @@ func (s *state6) GetAllocation(clientIdAddr address.Address, allocationId verifr return nil, false, xerrors.Errorf("unsupported in actors v6") } + +func (s *state6) GetAllocations(clientIdAddr address.Address) (map[verifreg9.AllocationId]verifreg9.Allocation, error) { + + return nil, xerrors.Errorf("unsupported in actors v6") + +} + +func (s *state6) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*verifreg9.Claim, bool, error) { + + return nil, false, xerrors.Errorf("unsupported in actors v6") + +} + +func (s *state6) GetClaims(providerIdAddr address.Address) (map[verifreg9.ClaimId]verifreg9.Claim, error) { + + return nil, xerrors.Errorf("unsupported in actors v6") + +} diff --git a/chain/actors/builtin/verifreg/v7.go b/chain/actors/builtin/verifreg/v7.go index 27e02af43..c3b49a305 100644 --- a/chain/actors/builtin/verifreg/v7.go +++ b/chain/actors/builtin/verifreg/v7.go @@ -95,3 +95,21 @@ func (s *state7) GetAllocation(clientIdAddr address.Address, allocationId verifr return nil, false, xerrors.Errorf("unsupported in actors v7") } + +func (s *state7) GetAllocations(clientIdAddr address.Address) (map[verifreg9.AllocationId]verifreg9.Allocation, error) { + + return nil, xerrors.Errorf("unsupported in actors v7") + +} + +func (s *state7) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*verifreg9.Claim, bool, error) { + + return nil, false, xerrors.Errorf("unsupported in actors v7") + +} + +func (s *state7) GetClaims(providerIdAddr address.Address) (map[verifreg9.ClaimId]verifreg9.Claim, error) { + + return nil, xerrors.Errorf("unsupported in actors v7") + +} diff --git a/chain/actors/builtin/verifreg/v8.go b/chain/actors/builtin/verifreg/v8.go index 31c529af7..36d219fa0 100644 --- a/chain/actors/builtin/verifreg/v8.go +++ b/chain/actors/builtin/verifreg/v8.go @@ -95,3 +95,21 @@ func (s *state8) GetAllocation(clientIdAddr address.Address, allocationId verifr return nil, false, xerrors.Errorf("unsupported in actors v8") } + +func (s *state8) GetAllocations(clientIdAddr address.Address) (map[verifreg9.AllocationId]verifreg9.Allocation, error) { + + return nil, xerrors.Errorf("unsupported in actors v8") + +} + +func (s *state8) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*verifreg9.Claim, bool, error) { + + return nil, false, xerrors.Errorf("unsupported in actors v8") + +} + +func (s *state8) GetClaims(providerIdAddr address.Address) (map[verifreg9.ClaimId]verifreg9.Claim, error) { + + return nil, xerrors.Errorf("unsupported in actors v8") + +} diff --git a/chain/actors/builtin/verifreg/v9.go b/chain/actors/builtin/verifreg/v9.go index 5bac7f6b7..5c84c7041 100644 --- a/chain/actors/builtin/verifreg/v9.go +++ b/chain/actors/builtin/verifreg/v9.go @@ -95,3 +95,21 @@ func (s *state9) GetAllocation(clientIdAddr address.Address, allocationId verifr return s.FindAllocation(s.store, clientIdAddr, allocationId) } + +func (s *state9) GetAllocations(clientIdAddr address.Address) (map[verifreg9.AllocationId]verifreg9.Allocation, error) { + + return s.LoadAllocationsToMap(s.store, clientIdAddr) + +} + +func (s *state9) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*verifreg9.Claim, bool, error) { + + return s.FindClaim(s.store, providerIdAddr, claimId) + +} + +func (s *state9) GetClaims(providerIdAddr address.Address) (map[verifreg9.ClaimId]verifreg9.Claim, error) { + + return s.LoadClaimsToMap(s.store, providerIdAddr) + +} diff --git a/chain/actors/builtin/verifreg/verifreg.go b/chain/actors/builtin/verifreg/verifreg.go index 70886aeb6..300307dbb 100644 --- a/chain/actors/builtin/verifreg/verifreg.go +++ b/chain/actors/builtin/verifreg/verifreg.go @@ -116,5 +116,8 @@ type State interface { ForEachVerifier(func(addr address.Address, dcap abi.StoragePower) error) error ForEachClient(func(addr address.Address, dcap abi.StoragePower) error) error GetAllocation(clientIdAddr address.Address, allocationId verifregtypes.AllocationId) (*verifregtypes.Allocation, bool, error) + GetAllocations(clientIdAddr address.Address) (map[verifregtypes.AllocationId]verifregtypes.Allocation, error) + GetClaim(providerIdAddr address.Address, claimId verifregtypes.ClaimId) (*verifregtypes.Claim, bool, error) + GetClaims(providerIdAddr address.Address) (map[verifregtypes.ClaimId]verifregtypes.Claim, error) GetState() interface{} } diff --git a/documentation/en/api-v0-methods.md b/documentation/en/api-v0-methods.md index 64f19ebe6..058b145a5 100644 --- a/documentation/en/api-v0-methods.md +++ b/documentation/en/api-v0-methods.md @@ -170,6 +170,9 @@ * [StateGetActor](#StateGetActor) * [StateGetAllocation](#StateGetAllocation) * [StateGetAllocationForPendingDeal](#StateGetAllocationForPendingDeal) + * [StateGetAllocations](#StateGetAllocations) + * [StateGetClaim](#StateGetClaim) + * [StateGetClaims](#StateGetClaims) * [StateGetNetworkParams](#StateGetNetworkParams) * [StateGetRandomnessFromBeacon](#StateGetRandomnessFromBeacon) * [StateGetRandomnessFromTickets](#StateGetRandomnessFromTickets) @@ -5317,6 +5320,90 @@ Response: } ``` +### StateGetAllocations +StateGetAllocations returns the all the allocations for a given client. + + +Perms: read + +Inputs: +```json +[ + "f01234", + [ + { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + { + "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" + } + ] +] +``` + +Response: `{}` + +### StateGetClaim +StateGetClaim returns the claim for a given address and claim ID. + + +Perms: read + +Inputs: +```json +[ + "f01234", + 0, + [ + { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + { + "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" + } + ] +] +``` + +Response: +```json +{ + "Provider": 1000, + "Client": 1000, + "Data": { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + "Size": 1032, + "TermMin": 10101, + "TermMax": 10101, + "TermStart": 10101, + "Sector": 9 +} +``` + +### StateGetClaims +StateGetClaims returns the all the claims for a given provider. + + +Perms: read + +Inputs: +```json +[ + "f01234", + [ + { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + { + "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" + } + ] +] +``` + +Response: `{}` + ### StateGetNetworkParams StateGetNetworkParams return current network params diff --git a/documentation/en/api-v1-unstable-methods.md b/documentation/en/api-v1-unstable-methods.md index f8394175f..8a7bc3c29 100644 --- a/documentation/en/api-v1-unstable-methods.md +++ b/documentation/en/api-v1-unstable-methods.md @@ -180,7 +180,10 @@ * [StateGetActor](#StateGetActor) * [StateGetAllocation](#StateGetAllocation) * [StateGetAllocationForPendingDeal](#StateGetAllocationForPendingDeal) + * [StateGetAllocations](#StateGetAllocations) * [StateGetBeaconEntry](#StateGetBeaconEntry) + * [StateGetClaim](#StateGetClaim) + * [StateGetClaims](#StateGetClaims) * [StateGetNetworkParams](#StateGetNetworkParams) * [StateGetRandomnessFromBeacon](#StateGetRandomnessFromBeacon) * [StateGetRandomnessFromTickets](#StateGetRandomnessFromTickets) @@ -5800,6 +5803,29 @@ Response: } ``` +### StateGetAllocations +StateGetAllocations returns the all the allocations for a given client. + + +Perms: read + +Inputs: +```json +[ + "f01234", + [ + { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + { + "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" + } + ] +] +``` + +Response: `{}` + ### 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 @@ -5823,6 +5849,67 @@ Response: } ``` +### StateGetClaim +StateGetClaim returns the claim for a given address and claim ID. + + +Perms: read + +Inputs: +```json +[ + "f01234", + 0, + [ + { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + { + "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" + } + ] +] +``` + +Response: +```json +{ + "Provider": 1000, + "Client": 1000, + "Data": { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + "Size": 1032, + "TermMin": 10101, + "TermMax": 10101, + "TermStart": 10101, + "Sector": 9 +} +``` + +### StateGetClaims +StateGetClaims returns the all the claims for a given provider. + + +Perms: read + +Inputs: +```json +[ + "f01234", + [ + { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + }, + { + "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" + } + ] +] +``` + +Response: `{}` + ### StateGetNetworkParams StateGetNetworkParams return current network params diff --git a/itests/pending_deal_allocation_test.go b/itests/pending_deal_allocation_test.go index fe08431d7..a9ce84375 100644 --- a/itests/pending_deal_allocation_test.go +++ b/itests/pending_deal_allocation_test.go @@ -188,4 +188,10 @@ func TestGetAllocationForPendingDeal(t *testing.T) { allocation, err := api.StateGetAllocationForPendingDeal(ctx, dealIds[0], types.EmptyTSK) require.NoError(t, err) require.Equal(t, dealProposal.PieceCID, allocation.Data) + + allocations, err := api.StateGetAllocations(ctx, verifiedClientAddr, types.EmptyTSK) + require.NoError(t, err) + for _, alloc := range allocations { + require.Equal(t, alloc, *allocation) + } } diff --git a/node/impl/full/state.go b/node/impl/full/state.go index 47a628aed..5a14447c3 100644 --- a/node/impl/full/state.go +++ b/node/impl/full/state.go @@ -813,7 +813,7 @@ func (a *StateAPI) StateGetAllocation(ctx context.Context, clientAddr address.Ad allocation, found, err := st.GetAllocation(idAddr, allocationId) if err != nil { - return nil, err + return nil, xerrors.Errorf("getting allocation: %w", err) } if !found { return nil, nil @@ -822,6 +822,81 @@ func (a *StateAPI) StateGetAllocation(ctx context.Context, clientAddr address.Ad return allocation, nil } +func (a *StateAPI) StateGetAllocations(ctx context.Context, clientAddr address.Address, tsk types.TipSetKey) (map[verifregtypes.AllocationId]verifregtypes.Allocation, error) { + idAddr, err := a.StateLookupID(ctx, clientAddr, tsk) + if err != nil { + return nil, err + } + + ts, err := a.Chain.GetTipSetFromKey(ctx, tsk) + if err != nil { + return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err) + } + + st, err := a.StateManager.GetVerifregState(ctx, ts) + if err != nil { + return nil, xerrors.Errorf("loading verifreg state: %w", err) + } + + allocations, err := st.GetAllocations(idAddr) + if err != nil { + return nil, xerrors.Errorf("getting allocations: %w", err) + } + + return allocations, nil +} + +func (a *StateAPI) StateGetClaim(ctx context.Context, providerAddr address.Address, claimId verifregtypes.ClaimId, tsk types.TipSetKey) (*verifregtypes.Claim, error) { + idAddr, err := a.StateLookupID(ctx, providerAddr, tsk) + if err != nil { + return nil, err + } + + ts, err := a.Chain.GetTipSetFromKey(ctx, tsk) + if err != nil { + return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err) + } + + st, err := a.StateManager.GetVerifregState(ctx, ts) + if err != nil { + return nil, err + } + + claim, found, err := st.GetClaim(idAddr, claimId) + if err != nil { + return nil, xerrors.Errorf("getting claim: %w", err) + } + if !found { + return nil, nil + } + + return claim, nil +} + +func (a *StateAPI) StateGetClaims(ctx context.Context, providerAddr address.Address, tsk types.TipSetKey) (map[verifregtypes.ClaimId]verifregtypes.Claim, error) { + idAddr, err := a.StateLookupID(ctx, providerAddr, tsk) + if err != nil { + return nil, err + } + + ts, err := a.Chain.GetTipSetFromKey(ctx, tsk) + if err != nil { + return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err) + } + + st, err := a.StateManager.GetVerifregState(ctx, ts) + if err != nil { + return nil, xerrors.Errorf("loading verifreg state: %w", err) + } + + claims, err := st.GetClaims(idAddr) + if err != nil { + return nil, xerrors.Errorf("getting claims: %w", err) + } + + return claims, nil +} + func (a *StateAPI) StateComputeDataCID(ctx context.Context, maddr address.Address, sectorType abi.RegisteredSealProof, deals []abi.DealID, tsk types.TipSetKey) (cid.Cid, error) { nv, err := a.StateNetworkVersion(ctx, tsk) if err != nil {