Deal tests on mock sectorbuilder
This commit is contained in:
parent
a2bcc1fec2
commit
2ca0c152ba
@ -649,7 +649,7 @@ func (sma StorageMarketActor) ComputeDataCommitment(act *types.Actor, vmctx type
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
commd, err := vmctx.Sys().GenerateDataCommitment(params.SectorSize, pieces)
|
commd, err := sectorbuilder.GenerateDataCommitment(params.SectorSize, pieces)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, aerrors.Absorb(err, 6, "failed to generate data commitment from pieces")
|
return nil, aerrors.Absorb(err, 6, "failed to generate data commitment from pieces")
|
||||||
}
|
}
|
||||||
|
@ -56,8 +56,6 @@ type VMSyscalls struct {
|
|||||||
candidates []sectorbuilder.EPostCandidate,
|
candidates []sectorbuilder.EPostCandidate,
|
||||||
proverID address.Address,
|
proverID address.Address,
|
||||||
faults uint64) (bool, error)
|
faults uint64) (bool, error)
|
||||||
|
|
||||||
GenerateDataCommitment func(ssize uint64, pieces []sectorbuilder.PublicPieceInfo) ([sectorbuilder.CommLen]byte, error)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type storageWrapper struct {
|
type storageWrapper struct {
|
||||||
|
@ -25,6 +25,5 @@ func Syscalls(verifier sectorbuilder.Verifier) *types.VMSyscalls {
|
|||||||
return ok, nil
|
return ok, nil
|
||||||
},
|
},
|
||||||
VerifyFallbackPost: verifier.VerifyFallbackPost,
|
VerifyFallbackPost: verifier.VerifyFallbackPost,
|
||||||
GenerateDataCommitment: verifier.GenerateDataCommitment,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,40 +5,36 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/markets/retrievaladapter"
|
"github.com/filecoin-project/go-data-transfer/impl/graphsync"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-fil-markets/retrievalmarket"
|
"github.com/filecoin-project/go-fil-markets/retrievalmarket"
|
||||||
"github.com/filecoin-project/go-fil-markets/retrievalmarket/discovery"
|
"github.com/filecoin-project/go-fil-markets/retrievalmarket/discovery"
|
||||||
retrievalimpl "github.com/filecoin-project/go-fil-markets/retrievalmarket/impl"
|
retrievalimpl "github.com/filecoin-project/go-fil-markets/retrievalmarket/impl"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-fil-markets/storagemarket"
|
"github.com/filecoin-project/go-fil-markets/storagemarket"
|
||||||
|
deals "github.com/filecoin-project/go-fil-markets/storagemarket/impl"
|
||||||
|
storageimpl "github.com/filecoin-project/go-fil-markets/storagemarket/impl"
|
||||||
"github.com/filecoin-project/go-statestore"
|
"github.com/filecoin-project/go-statestore"
|
||||||
"github.com/filecoin-project/lotus/node/modules/helpers"
|
|
||||||
"github.com/filecoin-project/lotus/paych"
|
|
||||||
|
|
||||||
"github.com/ipfs/go-bitswap"
|
"github.com/ipfs/go-bitswap"
|
||||||
"github.com/ipfs/go-bitswap/network"
|
"github.com/ipfs/go-bitswap/network"
|
||||||
graphsync "github.com/ipfs/go-graphsync/impl"
|
|
||||||
"github.com/ipfs/go-graphsync/ipldbridge"
|
|
||||||
gsnet "github.com/ipfs/go-graphsync/network"
|
|
||||||
"github.com/ipfs/go-graphsync/storeutil"
|
|
||||||
"github.com/libp2p/go-libp2p-core/host"
|
|
||||||
"github.com/libp2p/go-libp2p-core/routing"
|
|
||||||
|
|
||||||
"github.com/ipfs/go-blockservice"
|
"github.com/ipfs/go-blockservice"
|
||||||
"github.com/ipfs/go-datastore"
|
"github.com/ipfs/go-datastore"
|
||||||
"github.com/ipfs/go-datastore/namespace"
|
"github.com/ipfs/go-datastore/namespace"
|
||||||
"github.com/ipfs/go-filestore"
|
"github.com/ipfs/go-filestore"
|
||||||
|
graphsync "github.com/ipfs/go-graphsync/impl"
|
||||||
|
"github.com/ipfs/go-graphsync/ipldbridge"
|
||||||
|
gsnet "github.com/ipfs/go-graphsync/network"
|
||||||
|
"github.com/ipfs/go-graphsync/storeutil"
|
||||||
blockstore "github.com/ipfs/go-ipfs-blockstore"
|
blockstore "github.com/ipfs/go-ipfs-blockstore"
|
||||||
"github.com/ipfs/go-merkledag"
|
"github.com/ipfs/go-merkledag"
|
||||||
|
"github.com/libp2p/go-libp2p-core/host"
|
||||||
|
"github.com/libp2p/go-libp2p-core/routing"
|
||||||
"go.uber.org/fx"
|
"go.uber.org/fx"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-data-transfer/impl/graphsync"
|
"github.com/filecoin-project/lotus/markets/retrievaladapter"
|
||||||
deals "github.com/filecoin-project/go-fil-markets/storagemarket/impl"
|
|
||||||
storageimpl "github.com/filecoin-project/go-fil-markets/storagemarket/impl"
|
|
||||||
payapi "github.com/filecoin-project/lotus/node/impl/paych"
|
payapi "github.com/filecoin-project/lotus/node/impl/paych"
|
||||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||||
|
"github.com/filecoin-project/lotus/node/modules/helpers"
|
||||||
"github.com/filecoin-project/lotus/node/repo"
|
"github.com/filecoin-project/lotus/node/repo"
|
||||||
|
"github.com/filecoin-project/lotus/paych"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ClientFstore(r repo.LockedRepo) (dtypes.ClientFilestore, error) {
|
func ClientFstore(r repo.LockedRepo) (dtypes.ClientFilestore, error) {
|
||||||
|
@ -22,7 +22,7 @@ func (m *Miner) pledgeSector(ctx context.Context, sectorID uint64, existingPiece
|
|||||||
deals := make([]actors.StorageDealProposal, len(sizes))
|
deals := make([]actors.StorageDealProposal, len(sizes))
|
||||||
for i, size := range sizes {
|
for i, size := range sizes {
|
||||||
release := m.sb.RateLimit()
|
release := m.sb.RateLimit()
|
||||||
commP, err := m.sb.GeneratePieceCommitment(io.LimitReader(rand.New(rand.NewSource(42)), int64(size)), size)
|
commP, err := sectorbuilder.GeneratePieceCommitment(io.LimitReader(rand.New(rand.NewSource(42)), int64(size)), size)
|
||||||
release()
|
release()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -263,12 +263,12 @@ func (sb *SBMock) GenerateEPostCandidates(sectorInfo sectorbuilder.SortedPublicS
|
|||||||
n = uint64(len(sectorInfo.Values()))
|
n = uint64(len(sectorInfo.Values()))
|
||||||
}
|
}
|
||||||
|
|
||||||
out := make([]sectorbuilder.EPostCandidate, len(sectorInfo.Values()))
|
out := make([]sectorbuilder.EPostCandidate, n)
|
||||||
|
|
||||||
seed := big.NewInt(0).SetBytes(challengeSeed[:])
|
seed := big.NewInt(0).SetBytes(challengeSeed[:])
|
||||||
start := seed.Mod(seed, big.NewInt(int64(len(sectorInfo.Values())))).Int64()
|
start := seed.Mod(seed, big.NewInt(int64(len(sectorInfo.Values())))).Int64()
|
||||||
|
|
||||||
for i := 0; uint64(i) < n; i++ {
|
for i := range out {
|
||||||
out[i] = sectorbuilder.EPostCandidate{
|
out[i] = sectorbuilder.EPostCandidate{
|
||||||
SectorID: uint64((int(start) + i) % len(sectorInfo.Values())),
|
SectorID: uint64((int(start) + i) % len(sectorInfo.Values())),
|
||||||
PartialTicket: challengeSeed,
|
PartialTicket: challengeSeed,
|
||||||
@ -280,12 +280,11 @@ func (sb *SBMock) GenerateEPostCandidates(sectorInfo sectorbuilder.SortedPublicS
|
|||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sb *SBMock) GeneratePieceCommitment(piece io.Reader, pieceSize uint64) (commP [sectorbuilder.CommLen]byte, err error) {
|
|
||||||
panic("implement me")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (sb *SBMock) ReadPieceFromSealedSector(sectorID uint64, offset uint64, size uint64, ticket []byte, commD []byte) (io.ReadCloser, error) {
|
func (sb *SBMock) ReadPieceFromSealedSector(sectorID uint64, offset uint64, size uint64, ticket []byte, commD []byte) (io.ReadCloser, error) {
|
||||||
panic("implement me")
|
if len(sb.sectors[sectorID].pieces) > 1 {
|
||||||
|
panic("implme")
|
||||||
|
}
|
||||||
|
return ioutil.NopCloser(io.LimitReader(bytes.NewReader(sb.sectors[sectorID].pieces[0][offset:]), int64(size))), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sb *SBMock) StageFakeData() (uint64, []sectorbuilder.PublicPieceInfo, error) {
|
func (sb *SBMock) StageFakeData() (uint64, []sectorbuilder.PublicPieceInfo, error) {
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package sbmock
|
package sbmock
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"crypto/sha256"
|
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-sectorbuilder"
|
||||||
)
|
)
|
||||||
|
|
||||||
func randB(n uint64) []byte {
|
func randB(n uint64) []byte {
|
||||||
@ -24,5 +26,9 @@ func commDR(in []byte) (out [32]byte) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func commD(b []byte) [32]byte {
|
func commD(b []byte) [32]byte {
|
||||||
return sha256.Sum256(b)
|
c, err := sectorbuilder.GeneratePieceCommitment(bytes.NewReader(b), uint64(len(b)))
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return c
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user