Propagate spec actor types more
This commit is contained in:
parent
bcea739cff
commit
939610a930
@ -102,7 +102,6 @@ func (t *SealTicket) UnmarshalCBOR(r io.Reader) error {
|
||||
if maj != cbg.MajUnsignedInt {
|
||||
return fmt.Errorf("wrong type for uint64 field")
|
||||
}
|
||||
t.BlockHeight = uint64(extra)
|
||||
// t.TicketBytes ([]uint8) (slice)
|
||||
case "TicketBytes":
|
||||
|
||||
|
@ -49,6 +49,7 @@ type sealingApi interface { // TODO: trim down
|
||||
ChainGetTipSetByHeight(context.Context, abi.ChainEpoch, *types.TipSet) (*types.TipSet, error)
|
||||
ChainGetBlockMessages(context.Context, cid.Cid) (*api.BlockMessages, error)
|
||||
ChainReadObj(context.Context, cid.Cid) ([]byte, error)
|
||||
ChainHasObj(context.Context, cid.Cid) (bool, error)
|
||||
|
||||
WalletSign(context.Context, address.Address, []byte) (*types.Signature, error)
|
||||
WalletBalance(context.Context, address.Address) (types.BigInt, error)
|
||||
|
29
states.go
29
states.go
@ -6,6 +6,7 @@ import (
|
||||
commcid "github.com/filecoin-project/go-fil-commcid"
|
||||
"github.com/filecoin-project/go-sectorbuilder/fs"
|
||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
@ -76,7 +77,7 @@ func (m *Sealing) handleUnsealed(ctx statemachine.Context, sector SectorInfo) er
|
||||
commD: rspco.CommD[:],
|
||||
commR: rspco.CommR[:],
|
||||
ticket: SealTicket{
|
||||
BlockHeight: ticket.BlockHeight,
|
||||
BlockHeight: abi.ChainEpoch(ticket.BlockHeight),
|
||||
TicketBytes: ticket.TicketBytes[:],
|
||||
},
|
||||
})
|
||||
@ -116,7 +117,7 @@ func (m *Sealing) handlePreCommitting(ctx statemachine.Context, sector SectorInf
|
||||
msg := &types.Message{
|
||||
To: m.maddr,
|
||||
From: m.worker,
|
||||
Method: actors.MAMethods.PreCommitSector,
|
||||
Method: builtin.MethodsMiner.PreCommitSector,
|
||||
Params: enc,
|
||||
Value: types.NewInt(0), // TODO: need to ensure sufficient collateral
|
||||
GasLimit: types.NewInt(1000000 /* i dont know help */),
|
||||
@ -187,13 +188,12 @@ func (m *Sealing) handleCommitting(ctx statemachine.Context, sector SectorInfo)
|
||||
|
||||
// TODO: Consider splitting states and persist proof for faster recovery
|
||||
|
||||
/*params := &actors.SectorProveCommitInfo{
|
||||
Proof: proof,
|
||||
SectorID: sector.SectorID,
|
||||
DealIDs: sector.deals(),
|
||||
}*/
|
||||
params := &miner.ProveCommitSectorParams{
|
||||
SectorNumber: sector.SectorID,
|
||||
Proof: abi.SealProof{ProofBytes:proof},
|
||||
}
|
||||
|
||||
enc, aerr := actors.SerializeParams(nil) // TODO: REFACTOR: Fix
|
||||
enc, aerr := actors.SerializeParams(params)
|
||||
if aerr != nil {
|
||||
return ctx.Send(SectorCommitFailed{xerrors.Errorf("could not serialize commit sector parameters: %w", aerr)})
|
||||
}
|
||||
@ -201,7 +201,7 @@ func (m *Sealing) handleCommitting(ctx statemachine.Context, sector SectorInfo)
|
||||
msg := &types.Message{
|
||||
To: m.maddr,
|
||||
From: m.worker,
|
||||
Method: actors.MAMethods.ProveCommitSector,
|
||||
Method: builtin.MethodsMiner.ProveCommitSector,
|
||||
Params: enc,
|
||||
Value: types.NewInt(0), // TODO: need to ensure sufficient collateral
|
||||
GasLimit: types.NewInt(1000000 /* i dont know help */),
|
||||
@ -260,10 +260,13 @@ func (m *Sealing) handleFaulty(ctx statemachine.Context, sector SectorInfo) erro
|
||||
// TODO: check if the fault has already been reported, and that this sector is even valid
|
||||
|
||||
// TODO: coalesce faulty sector reporting
|
||||
bf := types.NewBitField()
|
||||
bf.Set(uint64(sector.SectorID))
|
||||
/*bf := types.NewBitField()
|
||||
bf.Set(uint64(sector.SectorID))*/
|
||||
|
||||
enc, aerr := actors.SerializeParams(&actors.DeclareFaultsParams{bf})
|
||||
enc, aerr := actors.SerializeParams(&miner.DeclareTemporaryFaultsParams{
|
||||
SectorNumbers: []abi.SectorNumber{sector.SectorID},
|
||||
Duration: 99999999, // TODO: This is very unlikely to be the correct number
|
||||
})
|
||||
if aerr != nil {
|
||||
return xerrors.Errorf("failed to serialize declare fault params: %w", aerr)
|
||||
}
|
||||
@ -271,7 +274,7 @@ func (m *Sealing) handleFaulty(ctx statemachine.Context, sector SectorInfo) erro
|
||||
msg := &types.Message{
|
||||
To: m.maddr,
|
||||
From: m.worker,
|
||||
Method: actors.MAMethods.DeclareFaults,
|
||||
Method: builtin.MethodsMiner.DeclareTemporaryFaults,
|
||||
Params: enc,
|
||||
Value: types.NewInt(0), // TODO: need to ensure sufficient collateral
|
||||
GasLimit: types.NewInt(1000000 /* i dont know help */),
|
||||
|
@ -2,13 +2,17 @@ package sealing
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"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/util/adt"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/api/apibstore"
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/store"
|
||||
"github.com/filecoin-project/lotus/lib/statemachine"
|
||||
)
|
||||
|
||||
@ -28,7 +32,7 @@ func failedCooldown(ctx statemachine.Context, sector SectorInfo) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Sealing) checkPreCommitted(ctx statemachine.Context, sector SectorInfo) (*actors.PreCommittedSector, bool) {
|
||||
func (m *Sealing) checkPreCommitted(ctx statemachine.Context, sector SectorInfo) (*miner.SectorPreCommitOnChainInfo, bool) {
|
||||
act, err := m.api.StateGetActor(ctx.Context(), m.maddr, nil)
|
||||
if err != nil {
|
||||
log.Errorf("handleSealFailed(%d): temp error: %+v", sector.SectorID, err)
|
||||
@ -47,14 +51,14 @@ func (m *Sealing) checkPreCommitted(ctx statemachine.Context, sector SectorInfo)
|
||||
return nil, true
|
||||
}
|
||||
|
||||
pci, found := state.PreCommittedSectors[fmt.Sprint(sector.SectorID)]
|
||||
if found {
|
||||
// TODO: If not expired yet, we can just try reusing sealticket
|
||||
log.Warnf("sector %d found in miner preseal array", sector.SectorID)
|
||||
return pci, true
|
||||
var pci miner.SectorPreCommitOnChainInfo
|
||||
precommits := adt.AsMap(store.ActorStore(ctx.Context(), apibstore.NewAPIBlockstore(m.api)), state.PreCommittedSectors)
|
||||
if _, err := precommits.Get(adt.IntKey(sector.SectorID), &pci); err != nil {
|
||||
log.Error(err)
|
||||
return nil, true
|
||||
}
|
||||
|
||||
return nil, false
|
||||
return &pci, false
|
||||
}
|
||||
|
||||
func (m *Sealing) handleSealFailed(ctx statemachine.Context, sector SectorInfo) error {
|
||||
@ -92,8 +96,13 @@ func (m *Sealing) handlePreCommitFailed(ctx statemachine.Context, sector SectorI
|
||||
return nil // TODO: SeedWait needs this currently
|
||||
}
|
||||
|
||||
if string(pci.Info.CommR) != string(sector.CommR) {
|
||||
log.Warn("sector %d is precommitted on chain, with different CommR: %x != %x", sector.SectorID, pci.Info.CommR, sector.CommR)
|
||||
pciR, err := commcid.CIDToReplicaCommitmentV1(pci.Info.SealedCID)
|
||||
if err != nil {
|
||||
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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user