storageminer: Fix build

This commit is contained in:
Łukasz Magiera 2020-02-21 19:20:22 +01:00
parent 852e888232
commit 49ece5fddf
4 changed files with 29 additions and 54 deletions

View File

@ -4,6 +4,7 @@ package build
import (
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
)
var SectorSizes = []abi.SectorSize{
@ -19,13 +20,13 @@ const PropagationDelay = 6
// ElectionPeriodStart before starting fallback post computation
//
// Epochs
const FallbackPoStDelay = 30
const FallbackPoStDelay = miner.ProvingPeriod
// SlashablePowerDelay is the number of epochs after ElectionPeriodStart, after
// which the miner is slashed
//
// Epochs
const SlashablePowerDelay = 200
const SlashablePowerDelay = miner.ProvingPeriod * 3 // TODO: remove
// Epochs
const InteractivePoRepDelay = 8

View File

@ -88,16 +88,16 @@ var infoCmd = &cli.Command{
fmt.Printf("\tCommit: %d\n", wstat.CommitWait)
fmt.Printf("\tUnseal: %d\n", wstat.UnsealWait)
eps, err := api.StateMinerElectionPeriodStart(ctx, maddr, nil)
ps, err := api.StateMinerPostState(ctx, maddr, nil)
if err != nil {
return err
}
if eps != 0 {
if ps.ProvingPeriodStart != 0 {
head, err := api.ChainHead(ctx)
if err != nil {
return err
}
lastEps := int64(head.Height() - eps)
lastEps := int64(head.Height() - ps.ProvingPeriodStart)
lastEpsS := lastEps * build.BlockDelay
fallback := lastEps + build.FallbackPoStDelay
@ -107,10 +107,10 @@ var infoCmd = &cli.Command{
nextS := next * build.BlockDelay
fmt.Printf("PoSt Submissions:\n")
fmt.Printf("\tPrevious: Epoch %d (%d block(s), ~%dm %ds ago)\n", eps, lastEps, lastEpsS/60, lastEpsS%60)
fmt.Printf("\tFallback: Epoch %d (in %d blocks, ~%dm %ds)\n", eps+build.FallbackPoStDelay, fallback, fallbackS/60, fallbackS%60)
fmt.Printf("\tDeadline: Epoch %d (in %d blocks, ~%dm %ds)\n", eps+build.SlashablePowerDelay, next, nextS/60, nextS%60)
fmt.Printf("\tPrevious: Epoch %d (%d block(s), ~%dm %ds ago)\n", ps.ProvingPeriodStart, lastEps, lastEpsS/60, lastEpsS%60)
fmt.Printf("\tFallback: Epoch %d (in %d blocks, ~%dm %ds)\n", ps.ProvingPeriodStart+build.FallbackPoStDelay, fallback, fallbackS/60, fallbackS%60)
fmt.Printf("\tDeadline: Epoch %d (in %d blocks, ~%dm %ds)\n", ps.ProvingPeriodStart+build.SlashablePowerDelay, next, nextS/60, nextS%60)
fmt.Printf("\tConsecutive Failures: %d\n", ps.NumConsecutiveFailures)
} else {
fmt.Printf("Proving Period: Not Proving\n")
}

View File

@ -5,6 +5,10 @@ import (
"crypto/rand"
"encoding/json"
"fmt"
"github.com/filecoin-project/specs-actors/actors/builtin"
miner2 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
"github.com/filecoin-project/specs-actors/actors/builtin/power"
crypto2 "github.com/filecoin-project/specs-actors/actors/crypto"
"io/ioutil"
"os"
"path/filepath"
@ -12,8 +16,6 @@ import (
"github.com/filecoin-project/go-address"
cborutil "github.com/filecoin-project/go-cbor-util"
"github.com/filecoin-project/go-fil-markets/storagemarket"
deals "github.com/filecoin-project/go-fil-markets/storagemarket/impl"
paramfetch "github.com/filecoin-project/go-paramfetch"
"github.com/filecoin-project/go-sectorbuilder"
"github.com/filecoin-project/specs-actors/actors/abi"
@ -32,7 +34,6 @@ import (
"github.com/filecoin-project/lotus/chain/types"
lcli "github.com/filecoin-project/lotus/cli"
"github.com/filecoin-project/lotus/genesis"
"github.com/filecoin-project/lotus/markets/utils"
"github.com/filecoin-project/lotus/miner"
"github.com/filecoin-project/lotus/node/modules"
"github.com/filecoin-project/lotus/node/modules/dtypes"
@ -231,17 +232,11 @@ func migratePreSealMeta(ctx context.Context, api lapi.FullNode, presealDir strin
return xerrors.Errorf("reading preseal metadata: %w", err)
}
preseals := map[string]genesis.GenesisMiner{}
if err := json.Unmarshal(b, &preseals); err != nil {
meta := genesis.Miner{}
if err := json.Unmarshal(b, &meta); err != nil {
return xerrors.Errorf("unmarshaling preseal metadata: %w", err)
}
meta, ok := preseals[maddr.String()]
if !ok {
return xerrors.New("got wrong preseal info")
}
for _, sector := range meta.Sectors {
sectorKey := datastore.NewKey(sealing.SectorStorePrefix).ChildString(fmt.Sprint(sector.SectorID))
@ -278,6 +273,7 @@ func migratePreSealMeta(ctx context.Context, api lapi.FullNode, presealDir strin
return err
}
/* // TODO: Import deals into market
pnd, err := cborutil.AsIpld(sector.Deal)
if err != nil {
return err
@ -285,19 +281,12 @@ func migratePreSealMeta(ctx context.Context, api lapi.FullNode, presealDir strin
dealKey := datastore.NewKey(deals.ProviderDsPrefix).ChildString(pnd.Cid().String())
proposal, err := utils.ToSharedStorageDealProposal(&sector.Deal)
if err != nil {
return err
}
deal := &deals.MinerDeal{
MinerDeal: storagemarket.MinerDeal{
Proposal: *proposal,
ClientDealProposal: sector.Deal,
ProposalCid: pnd.Cid(),
State: storagemarket.StorageDealActive,
Ref: pnd.Cid(), // TODO: This is super wrong, but there
// are no params for CommP CIDs, we can't recover unixfs cid easily,
// and this isn't even used after the deal enters Complete state
DealID: dealID,
DealID: sector.,
},
}
@ -308,7 +297,7 @@ func migratePreSealMeta(ctx context.Context, api lapi.FullNode, presealDir strin
if err := mds.Put(dealKey, b); err != nil {
return err
}
}*/
}
return nil
@ -461,26 +450,12 @@ func makeHostKey(lr repo.LockedRepo) (crypto.PrivKey, error) {
}
func configureStorageMiner(ctx context.Context, api lapi.FullNode, addr address.Address, peerid peer.ID) error {
// This really just needs to be an api call at this point...
recp, err := api.StateCall(ctx, &types.Message{
To: addr,
From: addr,
Method: actors.MAMethods.GetWorkerAddr,
}, nil)
if err != nil {
return xerrors.Errorf("failed to get worker address: %w", err)
}
if recp.ExitCode != 0 {
return xerrors.Errorf("getWorkerAddr returned exit code %d", recp.ExitCode)
}
waddr, err := address.NewFromBytes(recp.Return)
waddr, err := api.StateMinerWorker(ctx, addr, nil)
if err != nil {
return xerrors.Errorf("getWorkerAddr returned bad address: %w", err)
}
enc, err := actors.SerializeParams(&actors.UpdatePeerIDParams{PeerID: peerid})
enc, err := actors.SerializeParams(&miner2.ChangePeerIDParams{NewID: peerid})
if err != nil {
return err
}
@ -488,7 +463,7 @@ func configureStorageMiner(ctx context.Context, api lapi.FullNode, addr address.
msg := &types.Message{
To: addr,
From: waddr,
Method: actors.MAMethods.UpdatePeerID,
Method: builtin.MethodsMiner.ChangePeerID,
Params: enc,
Value: types.NewInt(0),
GasPrice: types.NewInt(0),
@ -532,7 +507,7 @@ func createStorageMiner(ctx context.Context, api lapi.FullNode, peerid peer.ID,
if cctx.String("worker") != "" {
worker, err = address.NewFromString(cctx.String("worker"))
} else if cctx.Bool("create-worker-key") { // TODO: Do we need to force this if owner is Secpk?
worker, err = api.WalletNew(ctx, types.KTBLS)
worker, err = api.WalletNew(ctx, crypto2.SigTypeBLS)
}
// TODO: Transfer some initial funds to worker
if err != nil {
@ -544,11 +519,10 @@ func createStorageMiner(ctx context.Context, api lapi.FullNode, peerid peer.ID,
return address.Undef, err
}
params, err := actors.SerializeParams(&actors.CreateStorageMinerParams{
Owner: owner,
params, err := actors.SerializeParams(&power.CreateMinerParams{
Worker: worker,
SectorSize: abi.SectorSize(ssize),
PeerID: peerid,
Peer: peerid,
})
if err != nil {
return address.Undef, err
@ -559,7 +533,7 @@ func createStorageMiner(ctx context.Context, api lapi.FullNode, peerid peer.ID,
From: owner,
Value: types.BigAdd(collateral, types.BigDiv(collateral, types.NewInt(100))),
Method: actors.SPAMethods.CreateStorageMiner,
Method: builtin.MethodsPower.CreateMiner,
Params: params,
GasLimit: types.NewInt(10000000),

View File

@ -136,7 +136,7 @@ var sectorsListCmd = &cli.Command{
}
provingIDs := make(map[abi.SectorNumber]struct{}, len(pset))
for _, info := range pset {
provingIDs[info.SectorID] = struct{}{}
provingIDs[info.ID] = struct{}{}
}
sset, err := fullApi.StateMinerSectors(ctx, maddr, nil)
@ -145,7 +145,7 @@ var sectorsListCmd = &cli.Command{
}
commitedIDs := make(map[abi.SectorNumber]struct{}, len(pset))
for _, info := range sset {
commitedIDs[info.SectorID] = struct{}{}
commitedIDs[info.ID] = struct{}{}
}
sort.Slice(list, func(i, j int) bool {