more fixes for random garbage
This commit is contained in:
parent
d1c15a2666
commit
300264bee1
52
cbor_gen.go
52
cbor_gen.go
@ -348,16 +348,6 @@ func (t *Piece) MarshalCBOR(w io.Writer) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(t.CommP) > cbg.ByteArrayMaxLen {
|
|
||||||
return xerrors.Errorf("Byte array in field t.CommP was too long")
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.CommP)))); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if _, err := w.Write(t.CommP); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -447,10 +437,6 @@ func (t *Piece) UnmarshalCBOR(r io.Reader) error {
|
|||||||
if maj != cbg.MajByteString {
|
if maj != cbg.MajByteString {
|
||||||
return fmt.Errorf("expected byte array")
|
return fmt.Errorf("expected byte array")
|
||||||
}
|
}
|
||||||
t.CommP = make([]byte, extra)
|
|
||||||
if _, err := io.ReadFull(br, t.CommP); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("unknown struct field %d: '%s'", i, name)
|
return fmt.Errorf("unknown struct field %d: '%s'", i, name)
|
||||||
@ -553,17 +539,6 @@ func (t *SectorInfo) MarshalCBOR(w io.Writer) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(t.CommD) > cbg.ByteArrayMaxLen {
|
|
||||||
return xerrors.Errorf("Byte array in field t.CommD was too long")
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.CommD)))); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if _, err := w.Write(t.CommD); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// t.CommR ([]uint8) (slice)
|
// t.CommR ([]uint8) (slice)
|
||||||
if len("CommR") > cbg.MaxLength {
|
if len("CommR") > cbg.MaxLength {
|
||||||
return xerrors.Errorf("Value in field \"CommR\" was too long")
|
return xerrors.Errorf("Value in field \"CommR\" was too long")
|
||||||
@ -576,17 +551,6 @@ func (t *SectorInfo) MarshalCBOR(w io.Writer) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(t.CommR) > cbg.ByteArrayMaxLen {
|
|
||||||
return xerrors.Errorf("Byte array in field t.CommR was too long")
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.CommR)))); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if _, err := w.Write(t.CommR); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// t.Proof ([]uint8) (slice)
|
// t.Proof ([]uint8) (slice)
|
||||||
if len("Proof") > cbg.MaxLength {
|
if len("Proof") > cbg.MaxLength {
|
||||||
return xerrors.Errorf("Value in field \"Proof\" was too long")
|
return xerrors.Errorf("Value in field \"Proof\" was too long")
|
||||||
@ -622,10 +586,6 @@ func (t *SectorInfo) MarshalCBOR(w io.Writer) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := t.Ticket.MarshalCBOR(w); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// t.PreCommitMessage (cid.Cid) (struct)
|
// t.PreCommitMessage (cid.Cid) (struct)
|
||||||
if len("PreCommitMessage") > cbg.MaxLength {
|
if len("PreCommitMessage") > cbg.MaxLength {
|
||||||
return xerrors.Errorf("Value in field \"PreCommitMessage\" was too long")
|
return xerrors.Errorf("Value in field \"PreCommitMessage\" was too long")
|
||||||
@ -875,10 +835,6 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error {
|
|||||||
if maj != cbg.MajByteString {
|
if maj != cbg.MajByteString {
|
||||||
return fmt.Errorf("expected byte array")
|
return fmt.Errorf("expected byte array")
|
||||||
}
|
}
|
||||||
t.CommD = make([]byte, extra)
|
|
||||||
if _, err := io.ReadFull(br, t.CommD); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
// t.CommR ([]uint8) (slice)
|
// t.CommR ([]uint8) (slice)
|
||||||
case "CommR":
|
case "CommR":
|
||||||
|
|
||||||
@ -893,10 +849,6 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error {
|
|||||||
if maj != cbg.MajByteString {
|
if maj != cbg.MajByteString {
|
||||||
return fmt.Errorf("expected byte array")
|
return fmt.Errorf("expected byte array")
|
||||||
}
|
}
|
||||||
t.CommR = make([]byte, extra)
|
|
||||||
if _, err := io.ReadFull(br, t.CommR); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
// t.Proof ([]uint8) (slice)
|
// t.Proof ([]uint8) (slice)
|
||||||
case "Proof":
|
case "Proof":
|
||||||
|
|
||||||
@ -920,10 +872,6 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error {
|
|||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
if err := t.Ticket.UnmarshalCBOR(br); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// t.PreCommitMessage (cid.Cid) (struct)
|
// t.PreCommitMessage (cid.Cid) (struct)
|
||||||
case "PreCommitMessage":
|
case "PreCommitMessage":
|
||||||
|
26
checks.go
26
checks.go
@ -5,12 +5,10 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
"github.com/multiformats/go-multihash"
|
|
||||||
cbg "github.com/whyrusleeping/cbor-gen"
|
cbg "github.com/whyrusleeping/cbor-gen"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
commcid "github.com/filecoin-project/go-fil-commcid"
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/market"
|
"github.com/filecoin-project/specs-actors/actors/builtin/market"
|
||||||
|
|
||||||
@ -45,7 +43,7 @@ func checkPieces(ctx context.Context, si SectorInfo, api sealingApi) error {
|
|||||||
for i, piece := range si.Pieces {
|
for i, piece := range si.Pieces {
|
||||||
if piece.DealID == nil {
|
if piece.DealID == nil {
|
||||||
exp := zerocomm.ForSize(piece.Size)
|
exp := zerocomm.ForSize(piece.Size)
|
||||||
if string(piece.CommP) != string(exp[:]) {
|
if piece.CommP != exp {
|
||||||
return &ErrInvalidPiece{xerrors.Errorf("deal %d piece %d had non-zero CommP %+v", piece.DealID, i, piece.CommP)}
|
return &ErrInvalidPiece{xerrors.Errorf("deal %d piece %d had non-zero CommP %+v", piece.DealID, i, piece.CommP)}
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
@ -55,13 +53,8 @@ func checkPieces(ctx context.Context, si SectorInfo, api sealingApi) error {
|
|||||||
return &ErrApi{xerrors.Errorf("getting deal %d for piece %d: %w", piece.DealID, i, err)}
|
return &ErrApi{xerrors.Errorf("getting deal %d for piece %d: %w", piece.DealID, i, err)}
|
||||||
}
|
}
|
||||||
|
|
||||||
h, err := multihash.Decode(deal.Proposal.PieceCID.Hash())
|
if deal.Proposal.PieceCID != piece.CommP {
|
||||||
if err != nil {
|
return &ErrInvalidDeals{xerrors.Errorf("piece %d (or %d) of sector %d refers deal %d with wrong CommP: %x != %x", i, len(si.Pieces), si.SectorID, piece.DealID, piece.CommP, deal.Proposal.PieceCID)}
|
||||||
return &ErrInvalidDeals{xerrors.Errorf("decoding piece CID: %w", err)}
|
|
||||||
}
|
|
||||||
|
|
||||||
if string(h.Digest) != string(piece.CommP) {
|
|
||||||
return &ErrInvalidDeals{xerrors.Errorf("piece %d (or %d) of sector %d refers deal %d with wrong CommP: %x != %x", i, len(si.Pieces), si.SectorID, piece.DealID, piece.CommP, h.Digest)}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if piece.Size != deal.Proposal.PieceSize.Unpadded() {
|
if piece.Size != deal.Proposal.PieceSize.Unpadded() {
|
||||||
@ -84,14 +77,9 @@ func checkSeal(ctx context.Context, maddr address.Address, si SectorInfo, api se
|
|||||||
return &ErrApi{xerrors.Errorf("getting chain head: %w", err)}
|
return &ErrApi{xerrors.Errorf("getting chain head: %w", err)}
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize, err := api.StateMinerSectorSize(ctx, maddr, head.Key())
|
|
||||||
if err != nil {
|
|
||||||
return &ErrApi{err}
|
|
||||||
}
|
|
||||||
|
|
||||||
ccparams, err := actors.SerializeParams(&market.ComputeDataCommitmentParams{
|
ccparams, err := actors.SerializeParams(&market.ComputeDataCommitmentParams{
|
||||||
DealIDs: si.deals(),
|
DealIDs: si.deals(),
|
||||||
SectorSize: ssize,
|
SectorType: si.SectorType,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return xerrors.Errorf("computing params for ComputeDataCommitment: %w", err)
|
return xerrors.Errorf("computing params for ComputeDataCommitment: %w", err)
|
||||||
@ -118,12 +106,8 @@ func checkSeal(ctx context.Context, maddr address.Address, si SectorInfo, api se
|
|||||||
if err := c.UnmarshalCBOR(bytes.NewReader(r.Return)); err != nil {
|
if err := c.UnmarshalCBOR(bytes.NewReader(r.Return)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
cd, err := commcid.CIDToDataCommitmentV1(cid.Cid(c))
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if string(cd) != string(si.CommD) {
|
if cid.Cid(c) != *si.CommD {
|
||||||
return &ErrBadCommD{xerrors.Errorf("on chain CommD differs from sector: %x != %x", r.Return, si.CommD)}
|
return &ErrBadCommD{xerrors.Errorf("on chain CommD differs from sector: %x != %x", r.Return, si.CommD)}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,14 +66,16 @@ type SectorPackingFailed struct{ error }
|
|||||||
func (evt SectorPackingFailed) apply(*SectorInfo) {}
|
func (evt SectorPackingFailed) apply(*SectorInfo) {}
|
||||||
|
|
||||||
type SectorSealed struct {
|
type SectorSealed struct {
|
||||||
commR []byte
|
commR cid.Cid
|
||||||
commD []byte
|
commD cid.Cid
|
||||||
ticket SealTicket
|
ticket SealTicket
|
||||||
}
|
}
|
||||||
|
|
||||||
func (evt SectorSealed) apply(state *SectorInfo) {
|
func (evt SectorSealed) apply(state *SectorInfo) {
|
||||||
state.CommD = evt.commD
|
commd := evt.commD
|
||||||
state.CommR = evt.commR
|
state.CommD = &commd
|
||||||
|
commr := evt.commR
|
||||||
|
state.CommR = &commr
|
||||||
state.Ticket = evt.ticket
|
state.Ticket = evt.ticket
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,8 +39,8 @@ func (m *Sealing) pledgeSector(ctx context.Context, sectorID abi.SectorNumber, e
|
|||||||
existingPieceSizes = append(existingPieceSizes, size)
|
existingPieceSizes = append(existingPieceSizes, size)
|
||||||
|
|
||||||
out[i] = Piece{
|
out[i] = Piece{
|
||||||
Size: ppi.Size,
|
Size: ppi.Size.Unpadded(),
|
||||||
CommP: ppi.CommP[:],
|
CommP: ppi.PieceCID,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ const SectorStorePrefix = "/sectors"
|
|||||||
|
|
||||||
var log = logging.Logger("sectors")
|
var log = logging.Logger("sectors")
|
||||||
|
|
||||||
type TicketFn func(context.Context) (*sectorbuilder.SealTicket, error)
|
type TicketFn func(context.Context) (SealTicket, error)
|
||||||
|
|
||||||
type sealingApi interface { // TODO: trim down
|
type sealingApi interface { // TODO: trim down
|
||||||
// Call a read only method on actors (no interaction with the chain required)
|
// Call a read only method on actors (no interaction with the chain required)
|
||||||
@ -125,8 +125,8 @@ func (m *Sealing) SealPiece(ctx context.Context, size abi.UnpaddedPieceSize, r i
|
|||||||
{
|
{
|
||||||
DealID: &dealID,
|
DealID: &dealID,
|
||||||
|
|
||||||
Size: ppi.Size,
|
Size: ppi.Size.Unpadded(),
|
||||||
CommP: ppi.CommP[:],
|
CommP: ppi.PieceCID,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
19
states.go
19
states.go
@ -2,9 +2,9 @@ package sealing
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/crypto"
|
"github.com/filecoin-project/specs-actors/actors/crypto"
|
||||||
|
|
||||||
commcid "github.com/filecoin-project/go-fil-commcid"
|
|
||||||
"github.com/filecoin-project/go-sectorbuilder/fs"
|
"github.com/filecoin-project/go-sectorbuilder/fs"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
@ -69,18 +69,15 @@ func (m *Sealing) handleUnsealed(ctx statemachine.Context, sector SectorInfo) er
|
|||||||
return ctx.Send(SectorSealFailed{xerrors.Errorf("getting ticket failed: %w", err)})
|
return ctx.Send(SectorSealFailed{xerrors.Errorf("getting ticket failed: %w", err)})
|
||||||
}
|
}
|
||||||
|
|
||||||
rspco, err := m.sb.SealPreCommit(ctx.Context(), sector.SectorID, *ticket, sector.pieceInfos())
|
sealed, unsealed, err := m.sb.SealPreCommit(ctx.Context(), sector.SectorID, ticket.TicketBytes, sector.pieceInfos())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ctx.Send(SectorSealFailed{xerrors.Errorf("seal pre commit failed: %w", err)})
|
return ctx.Send(SectorSealFailed{xerrors.Errorf("seal pre commit failed: %w", err)})
|
||||||
}
|
}
|
||||||
|
|
||||||
return ctx.Send(SectorSealed{
|
return ctx.Send(SectorSealed{
|
||||||
commD: rspco.CommD[:],
|
commD: unsealed,
|
||||||
commR: rspco.CommR[:],
|
commR: sealed,
|
||||||
ticket: SealTicket{
|
ticket: ticket,
|
||||||
BlockHeight: abi.ChainEpoch(ticket.BlockHeight),
|
|
||||||
TicketBytes: ticket.TicketBytes[:],
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,7 +101,7 @@ func (m *Sealing) handlePreCommitting(ctx statemachine.Context, sector SectorInf
|
|||||||
SectorNumber: sector.SectorID,
|
SectorNumber: sector.SectorID,
|
||||||
RegisteredProof: abi.RegisteredProof_StackedDRG32GiBSeal,
|
RegisteredProof: abi.RegisteredProof_StackedDRG32GiBSeal,
|
||||||
|
|
||||||
SealedCID: commcid.ReplicaCommitmentV1ToCID(sector.CommR),
|
SealedCID: *sector.CommR,
|
||||||
SealRandEpoch: sector.Ticket.BlockHeight,
|
SealRandEpoch: sector.Ticket.BlockHeight,
|
||||||
DealIDs: sector.deals(),
|
DealIDs: sector.deals(),
|
||||||
}
|
}
|
||||||
@ -161,7 +158,7 @@ func (m *Sealing) handleWaitSeed(ctx statemachine.Context, sector SectorInfo) er
|
|||||||
|
|
||||||
ctx.Send(SectorSeedReady{seed: SealSeed{
|
ctx.Send(SectorSeedReady{seed: SealSeed{
|
||||||
BlockHeight: randHeight,
|
BlockHeight: randHeight,
|
||||||
TicketBytes: rand,
|
TicketBytes: abi.InteractiveSealRandomness(rand),
|
||||||
}})
|
}})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -182,7 +179,7 @@ func (m *Sealing) handleCommitting(ctx statemachine.Context, sector SectorInfo)
|
|||||||
|
|
||||||
log.Infof("KOMIT %d %x(%d); %x(%d); %v; r:%x; d:%x", sector.SectorID, sector.Ticket.TicketBytes, sector.Ticket.BlockHeight, sector.Seed.TicketBytes, sector.Seed.BlockHeight, sector.pieceInfos(), sector.CommR, sector.CommD)
|
log.Infof("KOMIT %d %x(%d); %x(%d); %v; r:%x; d:%x", sector.SectorID, sector.Ticket.TicketBytes, sector.Ticket.BlockHeight, sector.Seed.TicketBytes, sector.Seed.BlockHeight, sector.pieceInfos(), sector.CommR, sector.CommD)
|
||||||
|
|
||||||
proof, err := m.sb.SealCommit(ctx.Context(), sector.SectorID, sector.Ticket.SB(), sector.Seed.SB(), sector.pieceInfos(), sector.rspco())
|
proof, err := m.sb.SealCommit(ctx.Context(), sector.SectorID, sector.Ticket.TicketBytes, sector.Seed.TicketBytes, sector.pieceInfos(), *sector.CommR, *sector.CommD)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ctx.Send(SectorComputeProofFailed{xerrors.Errorf("computing seal proof failed: %w", err)})
|
return ctx.Send(SectorComputeProofFailed{xerrors.Errorf("computing seal proof failed: %w", err)})
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
commcid "github.com/filecoin-project/go-fil-commcid"
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||||
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
@ -96,13 +95,8 @@ func (m *Sealing) handlePreCommitFailed(ctx statemachine.Context, sector SectorI
|
|||||||
return nil // TODO: SeedWait needs this currently
|
return nil // TODO: SeedWait needs this currently
|
||||||
}
|
}
|
||||||
|
|
||||||
pciR, err := commcid.CIDToReplicaCommitmentV1(pci.Info.SealedCID)
|
if pci.Info.SealedCID != *sector.CommR {
|
||||||
if err != nil {
|
log.Warn("sector %d is precommitted on chain, with different CommR: %x != %x", sector.SectorID, pci.Info.SealedCID, sector.CommR)
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if string(pciR) != string(sector.CommR) {
|
|
||||||
log.Warn("sector %d is precommitted on chain, with different CommR: %x != %x", sector.SectorID, pciR, sector.CommR)
|
|
||||||
return nil // TODO: remove when the actor allows re-precommit
|
return nil // TODO: remove when the actor allows re-precommit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
49
types.go
49
types.go
@ -1,7 +1,6 @@
|
|||||||
package sealing
|
package sealing
|
||||||
|
|
||||||
import (
|
import (
|
||||||
sectorbuilder "github.com/filecoin-project/go-sectorbuilder"
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
@ -9,24 +8,12 @@ import (
|
|||||||
|
|
||||||
type SealTicket struct {
|
type SealTicket struct {
|
||||||
BlockHeight abi.ChainEpoch
|
BlockHeight abi.ChainEpoch
|
||||||
TicketBytes []byte
|
TicketBytes abi.SealRandomness
|
||||||
}
|
|
||||||
|
|
||||||
func (t *SealTicket) SB() sectorbuilder.SealTicket {
|
|
||||||
out := sectorbuilder.SealTicket{BlockHeight: uint64(t.BlockHeight)}
|
|
||||||
copy(out.TicketBytes[:], t.TicketBytes)
|
|
||||||
return out
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type SealSeed struct {
|
type SealSeed struct {
|
||||||
BlockHeight abi.ChainEpoch
|
BlockHeight abi.ChainEpoch
|
||||||
TicketBytes []byte
|
TicketBytes abi.InteractiveSealRandomness
|
||||||
}
|
|
||||||
|
|
||||||
func (t *SealSeed) SB() sectorbuilder.SealSeed {
|
|
||||||
out := sectorbuilder.SealSeed{BlockHeight: uint64(t.BlockHeight)}
|
|
||||||
copy(out.TicketBytes[:], t.TicketBytes)
|
|
||||||
return out
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *SealSeed) Equals(o *SealSeed) bool {
|
func (t *SealSeed) Equals(o *SealSeed) bool {
|
||||||
@ -37,13 +24,7 @@ type Piece struct {
|
|||||||
DealID *abi.DealID
|
DealID *abi.DealID
|
||||||
|
|
||||||
Size abi.UnpaddedPieceSize
|
Size abi.UnpaddedPieceSize
|
||||||
CommP []byte
|
CommP cid.Cid
|
||||||
}
|
|
||||||
|
|
||||||
func (p *Piece) ppi() (out sectorbuilder.PublicPieceInfo) {
|
|
||||||
out.Size = p.Size
|
|
||||||
copy(out.CommP[:], p.CommP)
|
|
||||||
return out
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Log struct {
|
type Log struct {
|
||||||
@ -61,13 +42,15 @@ type SectorInfo struct {
|
|||||||
SectorID abi.SectorNumber
|
SectorID abi.SectorNumber
|
||||||
Nonce uint64 // TODO: remove
|
Nonce uint64 // TODO: remove
|
||||||
|
|
||||||
|
SectorType abi.RegisteredProof
|
||||||
|
|
||||||
// Packing
|
// Packing
|
||||||
|
|
||||||
Pieces []Piece
|
Pieces []Piece
|
||||||
|
|
||||||
// PreCommit
|
// PreCommit
|
||||||
CommD []byte
|
CommD *cid.Cid
|
||||||
CommR []byte
|
CommR *cid.Cid
|
||||||
Proof []byte
|
Proof []byte
|
||||||
Ticket SealTicket
|
Ticket SealTicket
|
||||||
|
|
||||||
@ -88,10 +71,13 @@ type SectorInfo struct {
|
|||||||
Log []Log
|
Log []Log
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *SectorInfo) pieceInfos() []sectorbuilder.PublicPieceInfo {
|
func (t *SectorInfo) pieceInfos() []abi.PieceInfo {
|
||||||
out := make([]sectorbuilder.PublicPieceInfo, len(t.Pieces))
|
out := make([]abi.PieceInfo, len(t.Pieces))
|
||||||
for i, piece := range t.Pieces {
|
for i, piece := range t.Pieces {
|
||||||
out[i] = piece.ppi()
|
out[i] = abi.PieceInfo{
|
||||||
|
Size: piece.Size.Padded(),
|
||||||
|
PieceCID: piece.CommP,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
@ -114,12 +100,3 @@ func (t *SectorInfo) existingPieces() []abi.UnpaddedPieceSize {
|
|||||||
}
|
}
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *SectorInfo) rspco() sectorbuilder.RawSealPreCommitOutput {
|
|
||||||
var out sectorbuilder.RawSealPreCommitOutput
|
|
||||||
|
|
||||||
copy(out.CommD[:], t.CommD)
|
|
||||||
copy(out.CommR[:], t.CommR)
|
|
||||||
|
|
||||||
return out
|
|
||||||
}
|
|
||||||
|
@ -5,14 +5,17 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
"gotest.tools/assert"
|
"gotest.tools/assert"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-cbor-util"
|
cborutil "github.com/filecoin-project/go-cbor-util"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSectorInfoSelialization(t *testing.T) {
|
func TestSectorInfoSelialization(t *testing.T) {
|
||||||
d := abi.DealID(1234)
|
d := abi.DealID(1234)
|
||||||
|
|
||||||
|
dummyCid := builtin.AccountActorCodeID
|
||||||
|
|
||||||
si := &SectorInfo{
|
si := &SectorInfo{
|
||||||
State: 123,
|
State: 123,
|
||||||
SectorID: 234,
|
SectorID: 234,
|
||||||
@ -20,9 +23,9 @@ func TestSectorInfoSelialization(t *testing.T) {
|
|||||||
Pieces: []Piece{{
|
Pieces: []Piece{{
|
||||||
DealID: &d,
|
DealID: &d,
|
||||||
Size: 5,
|
Size: 5,
|
||||||
CommP: []byte{3},
|
CommP: dummyCid,
|
||||||
}},
|
}},
|
||||||
CommD: []byte{32, 4},
|
CommD: &dummyCid,
|
||||||
CommR: nil,
|
CommR: nil,
|
||||||
Proof: nil,
|
Proof: nil,
|
||||||
Ticket: SealTicket{
|
Ticket: SealTicket{
|
||||||
|
@ -5,8 +5,6 @@ import (
|
|||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/storage/sbmock"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -45,19 +43,3 @@ func TestFillersFromRem(t *testing.T) {
|
|||||||
testFill(t, ub, []abi.UnpaddedPieceSize{ub1, ub4})
|
testFill(t, ub, []abi.UnpaddedPieceSize{ub1, ub4})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFastPledge(t *testing.T) {
|
|
||||||
sz := abi.PaddedPieceSize(16 << 20)
|
|
||||||
|
|
||||||
s := Sealing{sb: sbmock.NewMockSectorBuilder(0, abi.SectorSize(sz))}
|
|
||||||
if _, err := s.fastPledgeCommitment(sz.Unpadded(), 5); err != nil {
|
|
||||||
t.Fatalf("%+v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
sz = abi.PaddedPieceSize(1024)
|
|
||||||
|
|
||||||
s = Sealing{sb: sbmock.NewMockSectorBuilder(0, abi.SectorSize(sz))}
|
|
||||||
if _, err := s.fastPledgeCommitment(sz.Unpadded(), 64); err != nil {
|
|
||||||
t.Fatalf("%+v", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user