sealing: ComputeDataCid miner API
This commit is contained in:
parent
1aed631fe5
commit
d7c52f8adf
@ -54,6 +54,8 @@ type StorageMiner interface {
|
|||||||
|
|
||||||
ComputeWindowPoSt(ctx context.Context, dlIdx uint64, tsk types.TipSetKey) ([]miner.SubmitWindowedPoStParams, error) //perm:admin
|
ComputeWindowPoSt(ctx context.Context, dlIdx uint64, tsk types.TipSetKey) ([]miner.SubmitWindowedPoStParams, error) //perm:admin
|
||||||
|
|
||||||
|
ComputeDataCid(ctx context.Context, pieceSize abi.UnpaddedPieceSize, pieceData storage.Data) (abi.PieceInfo, error) //perm:admin
|
||||||
|
|
||||||
// Temp api for testing
|
// Temp api for testing
|
||||||
PledgeSector(context.Context) (abi.SectorID, error) //perm:write
|
PledgeSector(context.Context) (abi.SectorID, error) //perm:write
|
||||||
|
|
||||||
|
@ -641,6 +641,8 @@ type StorageMinerStruct struct {
|
|||||||
|
|
||||||
CheckProvable func(p0 context.Context, p1 abi.RegisteredPoStProof, p2 []storage.SectorRef, p3 bool) (map[abi.SectorNumber]string, error) `perm:"admin"`
|
CheckProvable func(p0 context.Context, p1 abi.RegisteredPoStProof, p2 []storage.SectorRef, p3 bool) (map[abi.SectorNumber]string, error) `perm:"admin"`
|
||||||
|
|
||||||
|
ComputeDataCid func(p0 context.Context, p1 abi.UnpaddedPieceSize, p2 storage.Data) (abi.PieceInfo, error) `perm:"admin"`
|
||||||
|
|
||||||
ComputeProof func(p0 context.Context, p1 []builtin.ExtendedSectorInfo, p2 abi.PoStRandomness, p3 abi.ChainEpoch, p4 abinetwork.Version) ([]builtin.PoStProof, error) `perm:"read"`
|
ComputeProof func(p0 context.Context, p1 []builtin.ExtendedSectorInfo, p2 abi.PoStRandomness, p3 abi.ChainEpoch, p4 abinetwork.Version) ([]builtin.PoStProof, error) `perm:"read"`
|
||||||
|
|
||||||
ComputeWindowPoSt func(p0 context.Context, p1 uint64, p2 types.TipSetKey) ([]miner.SubmitWindowedPoStParams, error) `perm:"admin"`
|
ComputeWindowPoSt func(p0 context.Context, p1 uint64, p2 types.TipSetKey) ([]miner.SubmitWindowedPoStParams, error) `perm:"admin"`
|
||||||
@ -3865,6 +3867,17 @@ func (s *StorageMinerStub) CheckProvable(p0 context.Context, p1 abi.RegisteredPo
|
|||||||
return *new(map[abi.SectorNumber]string), ErrNotSupported
|
return *new(map[abi.SectorNumber]string), ErrNotSupported
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *StorageMinerStruct) ComputeDataCid(p0 context.Context, p1 abi.UnpaddedPieceSize, p2 storage.Data) (abi.PieceInfo, error) {
|
||||||
|
if s.Internal.ComputeDataCid == nil {
|
||||||
|
return *new(abi.PieceInfo), ErrNotSupported
|
||||||
|
}
|
||||||
|
return s.Internal.ComputeDataCid(p0, p1, p2)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *StorageMinerStub) ComputeDataCid(p0 context.Context, p1 abi.UnpaddedPieceSize, p2 storage.Data) (abi.PieceInfo, error) {
|
||||||
|
return *new(abi.PieceInfo), ErrNotSupported
|
||||||
|
}
|
||||||
|
|
||||||
func (s *StorageMinerStruct) ComputeProof(p0 context.Context, p1 []builtin.ExtendedSectorInfo, p2 abi.PoStRandomness, p3 abi.ChainEpoch, p4 abinetwork.Version) ([]builtin.PoStProof, error) {
|
func (s *StorageMinerStruct) ComputeProof(p0 context.Context, p1 []builtin.ExtendedSectorInfo, p2 abi.PoStRandomness, p3 abi.ChainEpoch, p4 abinetwork.Version) ([]builtin.PoStProof, error) {
|
||||||
if s.Internal.ComputeProof == nil {
|
if s.Internal.ComputeProof == nil {
|
||||||
return *new([]builtin.PoStProof), ErrNotSupported
|
return *new([]builtin.PoStProof), ErrNotSupported
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -15,6 +15,7 @@
|
|||||||
* [Check](#Check)
|
* [Check](#Check)
|
||||||
* [CheckProvable](#CheckProvable)
|
* [CheckProvable](#CheckProvable)
|
||||||
* [Compute](#Compute)
|
* [Compute](#Compute)
|
||||||
|
* [ComputeDataCid](#ComputeDataCid)
|
||||||
* [ComputeProof](#ComputeProof)
|
* [ComputeProof](#ComputeProof)
|
||||||
* [ComputeWindowPoSt](#ComputeWindowPoSt)
|
* [ComputeWindowPoSt](#ComputeWindowPoSt)
|
||||||
* [Create](#Create)
|
* [Create](#Create)
|
||||||
@ -362,6 +363,29 @@ Response:
|
|||||||
## Compute
|
## Compute
|
||||||
|
|
||||||
|
|
||||||
|
### ComputeDataCid
|
||||||
|
|
||||||
|
|
||||||
|
Perms: admin
|
||||||
|
|
||||||
|
Inputs:
|
||||||
|
```json
|
||||||
|
[
|
||||||
|
1024,
|
||||||
|
{}
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
Response:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"Size": 1032,
|
||||||
|
"PieceCID": {
|
||||||
|
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### ComputeProof
|
### ComputeProof
|
||||||
|
|
||||||
|
|
||||||
|
8
extern/sector-storage/mock/mock.go
vendored
8
extern/sector-storage/mock/mock.go
vendored
@ -80,6 +80,10 @@ func (mgr *SectorMgr) SectorsUnsealPiece(ctx context.Context, sector storage.Sec
|
|||||||
panic("SectorMgr: unsealing piece: implement me")
|
panic("SectorMgr: unsealing piece: implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (mgr *SectorMgr) DataCid(ctx context.Context, size abi.UnpaddedPieceSize, r io.Reader) (abi.PieceInfo, error) {
|
||||||
|
panic("todo")
|
||||||
|
}
|
||||||
|
|
||||||
func (mgr *SectorMgr) AddPiece(ctx context.Context, sectorID storage.SectorRef, existingPieces []abi.UnpaddedPieceSize, size abi.UnpaddedPieceSize, r io.Reader) (abi.PieceInfo, error) {
|
func (mgr *SectorMgr) AddPiece(ctx context.Context, sectorID storage.SectorRef, existingPieces []abi.UnpaddedPieceSize, size abi.UnpaddedPieceSize, r io.Reader) (abi.PieceInfo, error) {
|
||||||
log.Warn("Add piece: ", sectorID, size, sectorID.ProofType)
|
log.Warn("Add piece: ", sectorID, size, sectorID.ProofType)
|
||||||
|
|
||||||
@ -537,6 +541,10 @@ func (mgr *SectorMgr) CheckProvable(ctx context.Context, pp abi.RegisteredPoStPr
|
|||||||
|
|
||||||
var _ storiface.WorkerReturn = &SectorMgr{}
|
var _ storiface.WorkerReturn = &SectorMgr{}
|
||||||
|
|
||||||
|
func (mgr *SectorMgr) ReturnDataCid(ctx context.Context, callID storiface.CallID, pi abi.PieceInfo, err *storiface.CallError) error {
|
||||||
|
panic("not supported")
|
||||||
|
}
|
||||||
|
|
||||||
func (mgr *SectorMgr) ReturnAddPiece(ctx context.Context, callID storiface.CallID, pi abi.PieceInfo, err *storiface.CallError) error {
|
func (mgr *SectorMgr) ReturnAddPiece(ctx context.Context, callID storiface.CallID, pi abi.PieceInfo, err *storiface.CallError) error {
|
||||||
panic("not supported")
|
panic("not supported")
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package itests
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"strings"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
@ -40,6 +41,21 @@ func TestWorkerPledge(t *testing.T) {
|
|||||||
miner.PledgeSectors(ctx, 1, 0, nil)
|
miner.PledgeSectors(ctx, 1, 0, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestWorkerDataCid(t *testing.T) {
|
||||||
|
ctx := context.Background()
|
||||||
|
_, miner, worker, _ := kit.EnsembleWorker(t, kit.WithAllSubsystems(), kit.ThroughRPC(), kit.WithNoLocalSealing(true),
|
||||||
|
kit.WithTaskTypes([]sealtasks.TaskType{sealtasks.TTFetch, sealtasks.TTCommit1, sealtasks.TTFinalize, sealtasks.TTDataCid, sealtasks.TTAddPiece, sealtasks.TTPreCommit1, sealtasks.TTPreCommit2, sealtasks.TTCommit2, sealtasks.TTUnseal})) // no mock proofs
|
||||||
|
|
||||||
|
e, err := worker.Enabled(ctx)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.True(t, e)
|
||||||
|
|
||||||
|
pi, err := miner.ComputeDataCid(ctx, 1016, strings.NewReader(strings.Repeat("a", 1016)))
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, abi.PaddedPieceSize(1024), pi.Size)
|
||||||
|
require.Equal(t, "baga6ea4seaqlhznlutptgfwhffupyer6txswamerq5fc2jlwf2lys2mm5jtiaeq", pi.PieceCID.String())
|
||||||
|
}
|
||||||
|
|
||||||
func TestWinningPostWorker(t *testing.T) {
|
func TestWinningPostWorker(t *testing.T) {
|
||||||
prevIns := build.InsecurePoStValidation
|
prevIns := build.InsecurePoStValidation
|
||||||
build.InsecurePoStValidation = false
|
build.InsecurePoStValidation = false
|
||||||
|
@ -425,6 +425,10 @@ func (sm *StorageMinerAPI) ComputeWindowPoSt(ctx context.Context, dlIdx uint64,
|
|||||||
return sm.WdPoSt.ComputePoSt(ctx, dlIdx, ts)
|
return sm.WdPoSt.ComputePoSt(ctx, dlIdx, ts)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (sm *StorageMinerAPI) ComputeDataCid(ctx context.Context, pieceSize abi.UnpaddedPieceSize, pieceData sto.Data) (abi.PieceInfo, error) {
|
||||||
|
return sm.StorageMgr.DataCid(ctx, pieceSize, pieceData)
|
||||||
|
}
|
||||||
|
|
||||||
func (sm *StorageMinerAPI) WorkerConnect(ctx context.Context, url string) error {
|
func (sm *StorageMinerAPI) WorkerConnect(ctx context.Context, url string) error {
|
||||||
w, err := connectRemoteWorker(ctx, sm, url)
|
w, err := connectRemoteWorker(ctx, sm, url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user