storageminer: Fix build
This commit is contained in:
parent
852e888232
commit
49ece5fddf
@ -4,6 +4,7 @@ package build
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||||
)
|
)
|
||||||
|
|
||||||
var SectorSizes = []abi.SectorSize{
|
var SectorSizes = []abi.SectorSize{
|
||||||
@ -19,13 +20,13 @@ const PropagationDelay = 6
|
|||||||
// ElectionPeriodStart before starting fallback post computation
|
// ElectionPeriodStart before starting fallback post computation
|
||||||
//
|
//
|
||||||
// Epochs
|
// Epochs
|
||||||
const FallbackPoStDelay = 30
|
const FallbackPoStDelay = miner.ProvingPeriod
|
||||||
|
|
||||||
// SlashablePowerDelay is the number of epochs after ElectionPeriodStart, after
|
// SlashablePowerDelay is the number of epochs after ElectionPeriodStart, after
|
||||||
// which the miner is slashed
|
// which the miner is slashed
|
||||||
//
|
//
|
||||||
// Epochs
|
// Epochs
|
||||||
const SlashablePowerDelay = 200
|
const SlashablePowerDelay = miner.ProvingPeriod * 3 // TODO: remove
|
||||||
|
|
||||||
// Epochs
|
// Epochs
|
||||||
const InteractivePoRepDelay = 8
|
const InteractivePoRepDelay = 8
|
||||||
|
@ -88,16 +88,16 @@ var infoCmd = &cli.Command{
|
|||||||
fmt.Printf("\tCommit: %d\n", wstat.CommitWait)
|
fmt.Printf("\tCommit: %d\n", wstat.CommitWait)
|
||||||
fmt.Printf("\tUnseal: %d\n", wstat.UnsealWait)
|
fmt.Printf("\tUnseal: %d\n", wstat.UnsealWait)
|
||||||
|
|
||||||
eps, err := api.StateMinerElectionPeriodStart(ctx, maddr, nil)
|
ps, err := api.StateMinerPostState(ctx, maddr, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if eps != 0 {
|
if ps.ProvingPeriodStart != 0 {
|
||||||
head, err := api.ChainHead(ctx)
|
head, err := api.ChainHead(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
lastEps := int64(head.Height() - eps)
|
lastEps := int64(head.Height() - ps.ProvingPeriodStart)
|
||||||
lastEpsS := lastEps * build.BlockDelay
|
lastEpsS := lastEps * build.BlockDelay
|
||||||
|
|
||||||
fallback := lastEps + build.FallbackPoStDelay
|
fallback := lastEps + build.FallbackPoStDelay
|
||||||
@ -107,10 +107,10 @@ var infoCmd = &cli.Command{
|
|||||||
nextS := next * build.BlockDelay
|
nextS := next * build.BlockDelay
|
||||||
|
|
||||||
fmt.Printf("PoSt Submissions:\n")
|
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("\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", eps+build.FallbackPoStDelay, fallback, fallbackS/60, fallbackS%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", eps+build.SlashablePowerDelay, next, nextS/60, nextS%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 {
|
} else {
|
||||||
fmt.Printf("Proving Period: Not Proving\n")
|
fmt.Printf("Proving Period: Not Proving\n")
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,10 @@ import (
|
|||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"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"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -12,8 +16,6 @@ import (
|
|||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
cborutil "github.com/filecoin-project/go-cbor-util"
|
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"
|
paramfetch "github.com/filecoin-project/go-paramfetch"
|
||||||
"github.com/filecoin-project/go-sectorbuilder"
|
"github.com/filecoin-project/go-sectorbuilder"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
@ -32,7 +34,6 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
lcli "github.com/filecoin-project/lotus/cli"
|
lcli "github.com/filecoin-project/lotus/cli"
|
||||||
"github.com/filecoin-project/lotus/genesis"
|
"github.com/filecoin-project/lotus/genesis"
|
||||||
"github.com/filecoin-project/lotus/markets/utils"
|
|
||||||
"github.com/filecoin-project/lotus/miner"
|
"github.com/filecoin-project/lotus/miner"
|
||||||
"github.com/filecoin-project/lotus/node/modules"
|
"github.com/filecoin-project/lotus/node/modules"
|
||||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
"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)
|
return xerrors.Errorf("reading preseal metadata: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
preseals := map[string]genesis.GenesisMiner{}
|
meta := genesis.Miner{}
|
||||||
|
if err := json.Unmarshal(b, &meta); err != nil {
|
||||||
if err := json.Unmarshal(b, &preseals); err != nil {
|
|
||||||
return xerrors.Errorf("unmarshaling preseal metadata: %w", err)
|
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 {
|
for _, sector := range meta.Sectors {
|
||||||
sectorKey := datastore.NewKey(sealing.SectorStorePrefix).ChildString(fmt.Sprint(sector.SectorID))
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* // TODO: Import deals into market
|
||||||
pnd, err := cborutil.AsIpld(sector.Deal)
|
pnd, err := cborutil.AsIpld(sector.Deal)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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())
|
dealKey := datastore.NewKey(deals.ProviderDsPrefix).ChildString(pnd.Cid().String())
|
||||||
|
|
||||||
proposal, err := utils.ToSharedStorageDealProposal(§or.Deal)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
deal := &deals.MinerDeal{
|
deal := &deals.MinerDeal{
|
||||||
MinerDeal: storagemarket.MinerDeal{
|
MinerDeal: storagemarket.MinerDeal{
|
||||||
Proposal: *proposal,
|
ClientDealProposal: sector.Deal,
|
||||||
ProposalCid: pnd.Cid(),
|
ProposalCid: pnd.Cid(),
|
||||||
State: storagemarket.StorageDealActive,
|
State: storagemarket.StorageDealActive,
|
||||||
Ref: pnd.Cid(), // TODO: This is super wrong, but there
|
DealID: sector.,
|
||||||
// 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,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,7 +297,7 @@ func migratePreSealMeta(ctx context.Context, api lapi.FullNode, presealDir strin
|
|||||||
|
|
||||||
if err := mds.Put(dealKey, b); err != nil {
|
if err := mds.Put(dealKey, b); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
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 {
|
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...
|
waddr, err := api.StateMinerWorker(ctx, addr, nil)
|
||||||
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)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return xerrors.Errorf("getWorkerAddr returned bad address: %w", err)
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -488,7 +463,7 @@ func configureStorageMiner(ctx context.Context, api lapi.FullNode, addr address.
|
|||||||
msg := &types.Message{
|
msg := &types.Message{
|
||||||
To: addr,
|
To: addr,
|
||||||
From: waddr,
|
From: waddr,
|
||||||
Method: actors.MAMethods.UpdatePeerID,
|
Method: builtin.MethodsMiner.ChangePeerID,
|
||||||
Params: enc,
|
Params: enc,
|
||||||
Value: types.NewInt(0),
|
Value: types.NewInt(0),
|
||||||
GasPrice: 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") != "" {
|
if cctx.String("worker") != "" {
|
||||||
worker, err = address.NewFromString(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?
|
} 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
|
// TODO: Transfer some initial funds to worker
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -544,11 +519,10 @@ func createStorageMiner(ctx context.Context, api lapi.FullNode, peerid peer.ID,
|
|||||||
return address.Undef, err
|
return address.Undef, err
|
||||||
}
|
}
|
||||||
|
|
||||||
params, err := actors.SerializeParams(&actors.CreateStorageMinerParams{
|
params, err := actors.SerializeParams(&power.CreateMinerParams{
|
||||||
Owner: owner,
|
|
||||||
Worker: worker,
|
Worker: worker,
|
||||||
SectorSize: abi.SectorSize(ssize),
|
SectorSize: abi.SectorSize(ssize),
|
||||||
PeerID: peerid,
|
Peer: peerid,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return address.Undef, err
|
return address.Undef, err
|
||||||
@ -559,7 +533,7 @@ func createStorageMiner(ctx context.Context, api lapi.FullNode, peerid peer.ID,
|
|||||||
From: owner,
|
From: owner,
|
||||||
Value: types.BigAdd(collateral, types.BigDiv(collateral, types.NewInt(100))),
|
Value: types.BigAdd(collateral, types.BigDiv(collateral, types.NewInt(100))),
|
||||||
|
|
||||||
Method: actors.SPAMethods.CreateStorageMiner,
|
Method: builtin.MethodsPower.CreateMiner,
|
||||||
Params: params,
|
Params: params,
|
||||||
|
|
||||||
GasLimit: types.NewInt(10000000),
|
GasLimit: types.NewInt(10000000),
|
||||||
|
@ -136,7 +136,7 @@ var sectorsListCmd = &cli.Command{
|
|||||||
}
|
}
|
||||||
provingIDs := make(map[abi.SectorNumber]struct{}, len(pset))
|
provingIDs := make(map[abi.SectorNumber]struct{}, len(pset))
|
||||||
for _, info := range pset {
|
for _, info := range pset {
|
||||||
provingIDs[info.SectorID] = struct{}{}
|
provingIDs[info.ID] = struct{}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
sset, err := fullApi.StateMinerSectors(ctx, maddr, nil)
|
sset, err := fullApi.StateMinerSectors(ctx, maddr, nil)
|
||||||
@ -145,7 +145,7 @@ var sectorsListCmd = &cli.Command{
|
|||||||
}
|
}
|
||||||
commitedIDs := make(map[abi.SectorNumber]struct{}, len(pset))
|
commitedIDs := make(map[abi.SectorNumber]struct{}, len(pset))
|
||||||
for _, info := range sset {
|
for _, info := range sset {
|
||||||
commitedIDs[info.SectorID] = struct{}{}
|
commitedIDs[info.ID] = struct{}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
sort.Slice(list, func(i, j int) bool {
|
sort.Slice(list, func(i, j int) bool {
|
||||||
|
Loading…
Reference in New Issue
Block a user