Propagate spec actor types more

This commit is contained in:
Łukasz Magiera 2020-02-12 08:44:20 +01:00
parent bcea739cff
commit 939610a930
4 changed files with 36 additions and 24 deletions

View File

@ -102,7 +102,6 @@ func (t *SealTicket) UnmarshalCBOR(r io.Reader) error {
if maj != cbg.MajUnsignedInt { if maj != cbg.MajUnsignedInt {
return fmt.Errorf("wrong type for uint64 field") return fmt.Errorf("wrong type for uint64 field")
} }
t.BlockHeight = uint64(extra)
// t.TicketBytes ([]uint8) (slice) // t.TicketBytes ([]uint8) (slice)
case "TicketBytes": case "TicketBytes":

View File

@ -49,6 +49,7 @@ type sealingApi interface { // TODO: trim down
ChainGetTipSetByHeight(context.Context, abi.ChainEpoch, *types.TipSet) (*types.TipSet, error) ChainGetTipSetByHeight(context.Context, abi.ChainEpoch, *types.TipSet) (*types.TipSet, error)
ChainGetBlockMessages(context.Context, cid.Cid) (*api.BlockMessages, error) ChainGetBlockMessages(context.Context, cid.Cid) (*api.BlockMessages, error)
ChainReadObj(context.Context, cid.Cid) ([]byte, error) ChainReadObj(context.Context, cid.Cid) ([]byte, error)
ChainHasObj(context.Context, cid.Cid) (bool, error)
WalletSign(context.Context, address.Address, []byte) (*types.Signature, error) WalletSign(context.Context, address.Address, []byte) (*types.Signature, error)
WalletBalance(context.Context, address.Address) (types.BigInt, error) WalletBalance(context.Context, address.Address) (types.BigInt, error)

View File

@ -6,6 +6,7 @@ import (
commcid "github.com/filecoin-project/go-fil-commcid" 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/miner" "github.com/filecoin-project/specs-actors/actors/builtin/miner"
"golang.org/x/xerrors" "golang.org/x/xerrors"
@ -76,7 +77,7 @@ func (m *Sealing) handleUnsealed(ctx statemachine.Context, sector SectorInfo) er
commD: rspco.CommD[:], commD: rspco.CommD[:],
commR: rspco.CommR[:], commR: rspco.CommR[:],
ticket: SealTicket{ ticket: SealTicket{
BlockHeight: ticket.BlockHeight, BlockHeight: abi.ChainEpoch(ticket.BlockHeight),
TicketBytes: ticket.TicketBytes[:], TicketBytes: ticket.TicketBytes[:],
}, },
}) })
@ -116,7 +117,7 @@ func (m *Sealing) handlePreCommitting(ctx statemachine.Context, sector SectorInf
msg := &types.Message{ msg := &types.Message{
To: m.maddr, To: m.maddr,
From: m.worker, From: m.worker,
Method: actors.MAMethods.PreCommitSector, Method: builtin.MethodsMiner.PreCommitSector,
Params: enc, Params: enc,
Value: types.NewInt(0), // TODO: need to ensure sufficient collateral Value: types.NewInt(0), // TODO: need to ensure sufficient collateral
GasLimit: types.NewInt(1000000 /* i dont know help */), 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 // TODO: Consider splitting states and persist proof for faster recovery
/*params := &actors.SectorProveCommitInfo{ params := &miner.ProveCommitSectorParams{
Proof: proof, SectorNumber: sector.SectorID,
SectorID: sector.SectorID, Proof: abi.SealProof{ProofBytes:proof},
DealIDs: sector.deals(), }
}*/
enc, aerr := actors.SerializeParams(nil) // TODO: REFACTOR: Fix enc, aerr := actors.SerializeParams(params)
if aerr != nil { if aerr != nil {
return ctx.Send(SectorCommitFailed{xerrors.Errorf("could not serialize commit sector parameters: %w", aerr)}) 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{ msg := &types.Message{
To: m.maddr, To: m.maddr,
From: m.worker, From: m.worker,
Method: actors.MAMethods.ProveCommitSector, Method: builtin.MethodsMiner.ProveCommitSector,
Params: enc, Params: enc,
Value: types.NewInt(0), // TODO: need to ensure sufficient collateral Value: types.NewInt(0), // TODO: need to ensure sufficient collateral
GasLimit: types.NewInt(1000000 /* i dont know help */), 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: check if the fault has already been reported, and that this sector is even valid
// TODO: coalesce faulty sector reporting // TODO: coalesce faulty sector reporting
bf := types.NewBitField() /*bf := types.NewBitField()
bf.Set(uint64(sector.SectorID)) 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 { if aerr != nil {
return xerrors.Errorf("failed to serialize declare fault params: %w", aerr) 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{ msg := &types.Message{
To: m.maddr, To: m.maddr,
From: m.worker, From: m.worker,
Method: actors.MAMethods.DeclareFaults, Method: builtin.MethodsMiner.DeclareTemporaryFaults,
Params: enc, Params: enc,
Value: types.NewInt(0), // TODO: need to ensure sufficient collateral Value: types.NewInt(0), // TODO: need to ensure sufficient collateral
GasLimit: types.NewInt(1000000 /* i dont know help */), GasLimit: types.NewInt(1000000 /* i dont know help */),

View File

@ -2,13 +2,17 @@ package sealing
import ( import (
"bytes" "bytes"
"fmt"
"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/util/adt"
"golang.org/x/xerrors" "golang.org/x/xerrors"
"github.com/filecoin-project/lotus/api" "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/actors"
"github.com/filecoin-project/lotus/chain/store"
"github.com/filecoin-project/lotus/lib/statemachine" "github.com/filecoin-project/lotus/lib/statemachine"
) )
@ -28,7 +32,7 @@ func failedCooldown(ctx statemachine.Context, sector SectorInfo) error {
return nil 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) act, err := m.api.StateGetActor(ctx.Context(), m.maddr, nil)
if err != nil { if err != nil {
log.Errorf("handleSealFailed(%d): temp error: %+v", sector.SectorID, err) 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 return nil, true
} }
pci, found := state.PreCommittedSectors[fmt.Sprint(sector.SectorID)] var pci miner.SectorPreCommitOnChainInfo
if found { precommits := adt.AsMap(store.ActorStore(ctx.Context(), apibstore.NewAPIBlockstore(m.api)), state.PreCommittedSectors)
// TODO: If not expired yet, we can just try reusing sealticket if _, err := precommits.Get(adt.IntKey(sector.SectorID), &pci); err != nil {
log.Warnf("sector %d found in miner preseal array", sector.SectorID) log.Error(err)
return pci, true return nil, true
} }
return nil, false return &pci, false
} }
func (m *Sealing) handleSealFailed(ctx statemachine.Context, sector SectorInfo) error { 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 return nil // TODO: SeedWait needs this currently
} }
if string(pci.Info.CommR) != string(sector.CommR) { pciR, err := commcid.CIDToReplicaCommitmentV1(pci.Info.SealedCID)
log.Warn("sector %d is precommitted on chain, with different CommR: %x != %x", sector.SectorID, pci.Info.CommR, sector.CommR) 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 return nil // TODO: remove when the actor allows re-precommit
} }