Fix compilation after dep updates

This commit is contained in:
Łukasz Magiera 2020-02-11 02:10:50 +01:00
parent a593a4f6f4
commit fa2c6605c2
22 changed files with 49 additions and 103 deletions

View File

@ -448,7 +448,7 @@ func (sma StorageMinerActor) SubmitFallbackPoSt(act *types.Actor, vmctx types.VM
return xerrors.New("could not decode comms")
}
si := ffi.PublicSectorInfo{
SectorID: id,
SectorNum: abi.SectorNumber(id),
}
commR := comms[0]
if len(commR) != len(si.CommR) {
@ -471,7 +471,7 @@ func (sma StorageMinerActor) SubmitFallbackPoSt(act *types.Actor, vmctx types.VM
copy(partial[:], t.Partial)
candidates = append(candidates, sectorbuilder.EPostCandidate{
PartialTicket: partial,
SectorID: t.SectorID,
SectorNum: t.SectorID,
SectorChallengeIndex: t.ChallengeIndex,
})
}

View File

@ -478,7 +478,7 @@ type eppProvider struct{}
func (epp *eppProvider) GenerateCandidates(ctx context.Context, _ sectorbuilder.SortedPublicSectorInfo, eprand []byte) ([]sectorbuilder.EPostCandidate, error) {
return []sectorbuilder.EPostCandidate{
{
SectorID: 1,
SectorNum: 1,
PartialTicket: [32]byte{},
Ticket: [32]byte{},
SectorChallengeIndex: 1,
@ -527,8 +527,8 @@ func IsRoundWinner(ctx context.Context, ts *types.TipSet, round int64, miner add
var commRa [32]byte
copy(commRa[:], s.CommR)
sinfos = append(sinfos, ffi.PublicSectorInfo{
SectorID: uint64(s.SectorID),
CommR: commRa,
SectorNum: s.SectorID,
CommR: commRa,
})
}
sectors := sectorbuilder.NewSortedPublicSectorInfo(sinfos)
@ -584,7 +584,7 @@ func ComputeProof(ctx context.Context, epp ElectionPoStProver, pi *ProofInput) (
copy(part, win.PartialTicket[:])
ept.Candidates = append(ept.Candidates, types.EPostTicket{
Partial: part,
SectorID: win.SectorID,
SectorID: win.SectorNum,
ChallengeIndex: win.SectorChallengeIndex,
})
}

View File

@ -222,7 +222,7 @@ func GetSectorsForElectionPost(ctx context.Context, sm *StateManager, ts *types.
var uselessBuffer [32]byte
copy(uselessBuffer[:], s.CommR)
uselessOtherArray = append(uselessOtherArray, ffi.PublicSectorInfo{
SectorID: uint64(s.SectorID),
SectorNum: s.SectorID,
CommR: uselessBuffer,
})
}

View File

@ -670,7 +670,7 @@ func (syncer *Syncer) VerifyElectionPoStProof(ctx context.Context, h *types.Bloc
copy(partial[:], t.Partial)
winners = append(winners, sectorbuilder.EPostCandidate{
PartialTicket: partial,
SectorID: t.SectorID,
SectorNum: t.SectorID,
SectorChallengeIndex: t.ChallengeIndex,
})
}

View File

@ -24,7 +24,7 @@ type Ticket struct {
type EPostTicket struct {
Partial []byte
SectorID uint64
SectorID abi.SectorNumber
ChallengeIndex uint64
}

View File

@ -530,7 +530,6 @@ func (t *EPostTicket) UnmarshalCBOR(r io.Reader) error {
if maj != cbg.MajUnsignedInt {
return fmt.Errorf("wrong type for uint64 field")
}
t.SectorID = uint64(extra)
// t.ChallengeIndex (uint64) (uint64)
maj, extra, err = cbg.CborReadHeader(br)

View File

@ -195,8 +195,8 @@ func main() {
precommit := time.Now()
sealedSectors = append(sealedSectors, ffi.PublicSectorInfo{
CommR: pco.CommR,
SectorID: uint64(i),
CommR: pco.CommR,
SectorNum: i,
})
seed := sectorbuilder.SealSeed{
@ -224,7 +224,7 @@ func main() {
if !c.Bool("skip-unseal") {
log.Info("Unsealing sector")
rc, err := sb.ReadPieceFromSealedSector(context.TODO(), 1, 0, uint64(sectorSize), ticket.TicketBytes[:], commD[:])
rc, err := sb.ReadPieceFromSealedSector(context.TODO(), 1, 0, abi.UnpaddedPieceSize(sectorSize), ticket.TicketBytes[:], commD[:])
if err != nil {
return err
}
@ -271,8 +271,8 @@ func main() {
for _, s := range genm.Sectors {
sealedSectors = append(sealedSectors, ffi.PublicSectorInfo{
CommR: s.CommR,
SectorID: uint64(s.SectorID),
CommR: s.CommR,
SectorNum: s.SectorID,
})
}
}

View File

@ -45,7 +45,7 @@ loop:
select {
case task := <-tasks:
log.Infof("New task: %d, sector %d, action: %d", task.TaskID, task.SectorID, task.Type)
log.Infof("New task: %d, sector %d, action: %d", task.TaskID, task.SectorNum, task.Type)
res := w.processTask(ctx, task)
@ -71,7 +71,7 @@ func (w *worker) processTask(ctx context.Context, task sectorbuilder.WorkerTask)
return errRes(xerrors.Errorf("unknown task type %d", task.Type))
}
if err := w.fetchSector(task.SectorID, task.Type); err != nil {
if err := w.fetchSector(task.SectorNum, task.Type); err != nil {
return errRes(xerrors.Errorf("fetching sector: %w", err))
}
@ -82,7 +82,7 @@ func (w *worker) processTask(ctx context.Context, task sectorbuilder.WorkerTask)
switch task.Type {
case sectorbuilder.WorkerPreCommit:
w.limiter.workLimit <- struct{}{}
rspco, err := w.sb.SealPreCommit(ctx, task.SectorID, task.SealTicket, task.Pieces)
rspco, err := w.sb.SealPreCommit(ctx, task.SectorNum, task.SealTicket, task.Pieces)
<-w.limiter.workLimit
if err != nil {
@ -90,20 +90,20 @@ func (w *worker) processTask(ctx context.Context, task sectorbuilder.WorkerTask)
}
res.Rspco = rspco.ToJson()
if err := w.push("sealed", task.SectorID); err != nil {
if err := w.push("sealed", task.SectorNum); err != nil {
return errRes(xerrors.Errorf("pushing precommited data: %w", err))
}
if err := w.push("cache", task.SectorID); err != nil {
if err := w.push("cache", task.SectorNum); err != nil {
return errRes(xerrors.Errorf("pushing precommited data: %w", err))
}
if err := w.remove("staging", task.SectorID); err != nil {
if err := w.remove("staging", task.SectorNum); err != nil {
return errRes(xerrors.Errorf("cleaning up staged sector: %w", err))
}
case sectorbuilder.WorkerCommit:
w.limiter.workLimit <- struct{}{}
proof, err := w.sb.SealCommit(ctx, task.SectorID, task.SealTicket, task.SealSeed, task.Pieces, task.Rspco)
proof, err := w.sb.SealCommit(ctx, task.SectorNum, task.SealTicket, task.SealSeed, task.Pieces, task.Rspco)
<-w.limiter.workLimit
if err != nil {
@ -112,11 +112,11 @@ func (w *worker) processTask(ctx context.Context, task sectorbuilder.WorkerTask)
res.Proof = proof
if err := w.push("cache", task.SectorID); err != nil {
if err := w.push("cache", task.SectorNum); err != nil {
return errRes(xerrors.Errorf("pushing precommited data: %w", err))
}
if err := w.remove("sealed", task.SectorID); err != nil {
if err := w.remove("sealed", task.SectorNum); err != nil {
return errRes(xerrors.Errorf("cleaning up sealed sector: %w", err))
}
}

View File

@ -99,7 +99,7 @@ var preSealCmd = &cli.Command{
return err
}
gm, err := seed.PreSeal(maddr, abi.SectorSize(c.Uint64("sector-size")), c.Uint64("sector-offset"), c.Int("num-sectors"), sbroot, []byte(c.String("ticket-preimage")))
gm, err := seed.PreSeal(maddr, abi.SectorSize(c.Uint64("sector-size")), abi.SectorNumber(c.Uint64("sector-offset")), c.Int("num-sectors"), sbroot, []byte(c.String("ticket-preimage")))
if err != nil {
return err
}
@ -272,7 +272,7 @@ var aggregateSectorDirsCmd = &cli.Command{
}
}
if err := agsb.SetLastSectorID(highestSectorID); err != nil {
if err := agsb.SetLastSectorNum(highestSectorID); err != nil {
return err
}

View File

@ -32,11 +32,11 @@ import (
var log = logging.Logger("preseal")
func PreSeal(maddr address.Address, ssize abi.SectorSize, offset uint64, sectors int, sbroot string, preimage []byte) (*genesis.GenesisMiner, error) {
func PreSeal(maddr address.Address, ssize abi.SectorSize, offset abi.SectorNumber, sectors int, sbroot string, preimage []byte) (*genesis.GenesisMiner, error) {
cfg := &sectorbuilder.Config{
Miner: maddr,
SectorSize: ssize,
FallbackLastID: offset,
FallbackLastNum: offset,
Paths: sectorbuilder.SimplePath(sbroot),
WorkerThreads: 2,
}
@ -57,7 +57,7 @@ func PreSeal(maddr address.Address, ssize abi.SectorSize, offset uint64, sectors
var sealedSectors []*genesis.PreSeal
for i := 0; i < sectors; i++ {
sid, err := sb.AcquireSectorId()
sid, err := sb.AcquireSectorNumber()
if err != nil {
return nil, err
}

1
go.mod
View File

@ -19,6 +19,7 @@ require (
github.com/filecoin-project/go-data-transfer v0.0.0-20191219005021-4accf56bd2ce
github.com/filecoin-project/go-fil-commcid v0.0.0-20200208005934-2b8bd03caca5
github.com/filecoin-project/go-fil-markets v0.0.0-20200206024724-973498b060e3
github.com/filecoin-project/go-padreader v0.0.0-20200210211231-548257017ca6
github.com/filecoin-project/go-paramfetch v0.0.1
github.com/filecoin-project/go-sectorbuilder v0.0.2-0.20200210220012-eb75ec747d6b
github.com/filecoin-project/go-statestore v0.1.0

2
go.sum
View File

@ -117,6 +117,8 @@ github.com/filecoin-project/go-fil-markets v0.0.0-20200206024724-973498b060e3 h1
github.com/filecoin-project/go-fil-markets v0.0.0-20200206024724-973498b060e3/go.mod h1:0d8NAXL4ecTLvxCpoc0cZd1XbRq9UtFT14BkITidVkc=
github.com/filecoin-project/go-padreader v0.0.0-20200130212543-892867c4edf9 h1:CQsjS+oWG96rk5YbeKpPw84fhbgc5H6/BGvrlPgd63A=
github.com/filecoin-project/go-padreader v0.0.0-20200130212543-892867c4edf9/go.mod h1:r0gyD7zvnqyRKSY8stil5G/LF0kXFgNzW/yR4vjga+Y=
github.com/filecoin-project/go-padreader v0.0.0-20200210211231-548257017ca6 h1:92PET+sx1Hb4W/8CgFwGuxaKbttwY+UNspYZTvXY0vs=
github.com/filecoin-project/go-padreader v0.0.0-20200210211231-548257017ca6/go.mod h1:0HgYnrkeSU4lu1p+LEOeDpFsNBssa0OGGriWdA4hvaE=
github.com/filecoin-project/go-paramfetch v0.0.0-20200102181131-b20d579f2878/go.mod h1:40kI2Gv16mwcRsHptI3OAV4nlOEU7wVDc4RgMylNFjU=
github.com/filecoin-project/go-paramfetch v0.0.1 h1:gV7bs5YaqlgpGFMiLxInGK2L1FyCXUE0rimz4L7ghoE=
github.com/filecoin-project/go-paramfetch v0.0.1/go.mod h1:fZzmf4tftbwf9S37XRifoJlz7nCjRdIrMGLR07dKLCc=

View File

@ -1,38 +0,0 @@
package padreader
import (
"io"
"math/bits"
sectorbuilder "github.com/filecoin-project/filecoin-ffi"
)
func PaddedSize(size uint64) uint64 {
logv := 64 - bits.LeadingZeros64(size)
sectSize := uint64(1 << logv)
bound := sectorbuilder.GetMaxUserBytesPerStagedSector(sectSize)
if size <= bound {
return bound
}
return sectorbuilder.GetMaxUserBytesPerStagedSector(1 << (logv + 1))
}
type nullReader struct{}
func (nr nullReader) Read(b []byte) (int, error) {
for i := range b {
b[i] = 0
}
return len(b), nil
}
func New(r io.Reader, size uint64) (io.Reader, uint64) {
padSize := PaddedSize(size)
return io.MultiReader(
io.LimitReader(r, int64(size)),
io.LimitReader(nullReader{}, int64(padSize-size)),
), padSize
}

View File

@ -1,19 +0,0 @@
package padreader
import (
"testing"
"gotest.tools/assert"
)
func TestComputePaddedSize(t *testing.T) {
assert.Equal(t, uint64(1040384), PaddedSize(1000000))
assert.Equal(t, uint64(1016), PaddedSize(548))
assert.Equal(t, uint64(1016), PaddedSize(1015))
assert.Equal(t, uint64(1016), PaddedSize(1016))
assert.Equal(t, uint64(2032), PaddedSize(1017))
assert.Equal(t, uint64(2032), PaddedSize(1024))
assert.Equal(t, uint64(4064), PaddedSize(2048))
}

View File

@ -33,7 +33,7 @@ func (rpn *retrievalProviderNode) UnsealSector(ctx context.Context, sectorID abi
if err != nil {
return nil, err
}
return rpn.sb.ReadPieceFromSealedSector(ctx, sectorID, offset, length, si.Ticket.TicketBytes, si.CommD)
return rpn.sb.ReadPieceFromSealedSector(ctx, sectorID, sectorbuilder.UnpaddedByteIndex(offset), abi.UnpaddedPieceSize(length), si.Ticket.TicketBytes, si.CommD)
}
func (rpn *retrievalProviderNode) SavePaymentVoucher(ctx context.Context, paymentChannel address.Address, voucher *retrievaltypes.SignedVoucher, proof []byte, expectedAmount retrievaltoken.TokenAmount) (retrievaltoken.TokenAmount, error) {

View File

@ -107,13 +107,13 @@ func (s *FPoStScheduler) checkFaults(ctx context.Context, ssi sectorbuilder.Sort
params := &actors.DeclareFaultsParams{Faults: types.NewBitField()}
for _, fault := range faults {
if _, ok := declaredFaults[abi.SectorNumber(fault.SectorID)]; ok {
if _, ok := declaredFaults[abi.SectorNumber(fault.SectorNum)]; ok {
continue
}
log.Warnf("new fault detected: sector %d: %s", fault.SectorID, fault.Err)
declaredFaults[abi.SectorNumber(fault.SectorID)] = struct{}{}
params.Faults.Set(fault.SectorID)
log.Warnf("new fault detected: sector %d: %s", fault.SectorNum, fault.Err)
declaredFaults[fault.SectorNum] = struct{}{}
params.Faults.Set(uint64(fault.SectorNum))
}
pc, err := params.Faults.Count()
@ -184,7 +184,7 @@ func (s *FPoStScheduler) runPost(ctx context.Context, eps abi.ChainEpoch, ts *ty
copy(part, sc.PartialTicket[:])
candidates[i] = types.EPostTicket{
Partial: part,
SectorID: sc.SectorID,
SectorID: sc.SectorNum,
ChallengeIndex: sc.SectorChallengeIndex,
}
}
@ -210,8 +210,8 @@ func (s *FPoStScheduler) sortedSectorInfo(ctx context.Context, ts *types.TipSet)
copy(commR[:], sector.CommR)
sbsi[k] = ffi.PublicSectorInfo{
SectorID: uint64(sector.SectorID),
CommR: commR,
SectorNum: sector.SectorID,
CommR: commR,
}
}

View File

@ -12,7 +12,7 @@ import (
// TODO: refactor this to be direct somehow
func (m *Miner) AllocatePiece(size uint64) (sectorID abi.SectorNumber, offset uint64, err error) {
func (m *Miner) AllocatePiece(size abi.UnpaddedPieceSize) (sectorID abi.SectorNumber, offset uint64, err error) {
return m.sealing.AllocatePiece(size)
}

View File

@ -128,7 +128,7 @@ func (m *Sealing) PledgeSector() error {
size := abi.PaddedPieceSize(m.sb.SectorSize()).Unpadded()
sid, err := m.sb.AcquireSectorId()
sid, err := m.sb.AcquireSectorNumber()
if err != nil {
log.Errorf("%+v", err)
return

View File

@ -12,13 +12,13 @@ import (
logging "github.com/ipfs/go-log/v2"
"golang.org/x/xerrors"
"github.com/filecoin-project/go-padreader"
"github.com/filecoin-project/go-sectorbuilder"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/chain/events"
"github.com/filecoin-project/lotus/chain/store"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/lib/padreader"
"github.com/filecoin-project/lotus/lib/statemachine"
)
@ -96,12 +96,12 @@ func (m *Sealing) Stop(ctx context.Context) error {
return m.sectors.Stop(ctx)
}
func (m *Sealing) AllocatePiece(size uint64) (sectorID abi.SectorNumber, offset uint64, err error) {
if padreader.PaddedSize(size) != size {
func (m *Sealing) AllocatePiece(size abi.UnpaddedPieceSize) (sectorID abi.SectorNumber, offset uint64, err error) {
if (padreader.PaddedSize(uint64(size))) != size {
return 0, 0, xerrors.Errorf("cannot allocate unpadded piece")
}
sid, err := m.sb.AcquireSectorId() // TODO: Put more than one thing in a sector
sid, err := m.sb.AcquireSectorNumber() // TODO: Put more than one thing in a sector
if err != nil {
return 0, 0, xerrors.Errorf("acquiring sector ID: %w", err)
}

View File

@ -41,7 +41,7 @@ type Piece struct {
}
func (p *Piece) ppi() (out sectorbuilder.PublicPieceInfo) {
out.Size = uint64(p.Size)
out.Size = p.Size
copy(out.CommP[:], p.CommP)
return out
}

View File

@ -71,7 +71,7 @@ func (m *Sealing) fastPledgeCommitment(size abi.UnpaddedPieceSize, parts uint64)
err = multierror.Append(err, perr)
}
out[i] = sectorbuilder.PublicPieceInfo{
Size: uint64(piece),
Size: piece,
CommP: commP,
}
lk.Unlock()

View File

@ -8,6 +8,7 @@ import (
"io"
"sync"
"github.com/filecoin-project/go-padreader"
sectorbuilder "github.com/filecoin-project/go-sectorbuilder"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/ipfs/go-datastore"
@ -17,8 +18,8 @@ import (
"golang.org/x/xerrors"
cborutil "github.com/filecoin-project/go-cbor-util"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/lib/padreader"
"github.com/filecoin-project/lotus/node/modules/dtypes"
"github.com/filecoin-project/lotus/storage"
)