Compute seal ticket internally, remove node ticket fn

This commit is contained in:
anorth 2020-04-23 10:09:52 +10:00
parent 1515cffb5d
commit 29460c440d
3 changed files with 9 additions and 9 deletions

View File

@ -50,12 +50,11 @@ type Sealing struct {
sectors *statemachine.StateGroup
sc SectorIDCounter
verif ffiwrapper.Verifier
tktFn TicketFn
pcp PreCommitPolicy
}
func New(api SealingAPI, events Events, maddr address.Address, ds datastore.Batching, sealer sectorstorage.SectorManager, sc SectorIDCounter, verif ffiwrapper.Verifier, tktFn TicketFn, pcp PreCommitPolicy) *Sealing {
func New(api SealingAPI, events Events, maddr address.Address, ds datastore.Batching, sealer sectorstorage.SectorManager, sc SectorIDCounter, verif ffiwrapper.Verifier, pcp PreCommitPolicy) *Sealing {
s := &Sealing{
api: api,
events: events,
@ -64,7 +63,6 @@ func New(api SealingAPI, events Events, maddr address.Address, ds datastore.Batc
sealer: sealer,
sc: sc,
verif: verif,
tktFn: tktFn,
pcp: pcp,
}

View File

@ -47,7 +47,7 @@ func (m *Sealing) handlePacking(ctx statemachine.Context, sector SectorInfo) err
}
func (m *Sealing) handlePreCommit1(ctx statemachine.Context, sector SectorInfo) error {
tok, _, err := m.api.ChainHead(ctx.Context())
tok, epoch, err := m.api.ChainHead(ctx.Context())
if err != nil {
log.Errorf("handlePreCommit1: api error, not proceeding: %+v", err)
return nil
@ -68,10 +68,16 @@ func (m *Sealing) handlePreCommit1(ctx statemachine.Context, sector SectorInfo)
}
log.Infow("performing sector replication...", "sector", sector.SectorNumber)
ticketValue, ticketEpoch, err := m.tktFn(ctx.Context(), tok)
ticketEpoch := epoch - miner.ChainFinalityish
buf := new(bytes.Buffer)
if err := m.maddr.MarshalCBOR(buf); err != nil {
return err
}
rand, err := m.api.ChainGetRandomness(ctx.Context(), tok, crypto.DomainSeparationTag_SealRandomness, ticketEpoch, buf.Bytes())
if err != nil {
return ctx.Send(SectorSealPreCommitFailed{xerrors.Errorf("getting ticket failed: %w", err)})
}
ticketValue := abi.SealRandomness(rand)
pc1o, err := m.sealer.SealPreCommit1(ctx.Context(), m.minerSector(sector.SectorNumber), ticketValue, sector.pieceInfos())
if err != nil {
@ -180,7 +186,6 @@ func (m *Sealing) handleWaitSeed(ctx statemachine.Context, sector SectorInfo) er
if err := m.maddr.MarshalCBOR(buf); err != nil {
return err
}
rand, err := m.api.ChainGetRandomness(ectx, tok, crypto.DomainSeparationTag_InteractiveSealChallengeSeed, randHeight, buf.Bytes())
if err != nil {
err = xerrors.Errorf("failed to get randomness for computing seal proof: %w", err)

View File

@ -2,7 +2,6 @@ package sealing
import (
"bytes"
"context"
"github.com/ipfs/go-cid"
@ -113,8 +112,6 @@ func (t *SectorInfo) existingPieceSizes() []abi.UnpaddedPieceSize {
return out
}
type TicketFn func(ctx context.Context, tok TipSetToken) (abi.SealRandomness, abi.ChainEpoch, error)
type SectorIDCounter interface {
Next() (abi.SectorNumber, error)
}