Some fixes and dev utils
This commit is contained in:
parent
8767d8c16b
commit
ed9279cf0c
@ -103,7 +103,7 @@ func (w *worker) processTask(ctx context.Context, task sectorbuilder.WorkerTask)
|
||||
return errRes(xerrors.Errorf("pushing precommited data: %w", err))
|
||||
}
|
||||
case sectorbuilder.WorkerCommit:
|
||||
proof, err := w.sb.SealCommit(task.SectorID, task.SealTicket, task.SealSeed, task.Pieces, nil, task.Rspco)
|
||||
proof, err := w.sb.SealCommit(task.SectorID, task.SealTicket, task.SealSeed, task.Pieces, task.Rspco)
|
||||
if err != nil {
|
||||
return errRes(xerrors.Errorf("comitting: %w", err))
|
||||
}
|
||||
@ -210,5 +210,5 @@ func (w *worker) fetchSector(sectorID uint64, typ sectorbuilder.WorkerTaskType)
|
||||
}
|
||||
|
||||
func errRes(err error) sectorbuilder.SealRes {
|
||||
return sectorbuilder.SealRes{Err: err}
|
||||
return sectorbuilder.SealRes{Err: err.Error()}
|
||||
}
|
||||
|
@ -207,6 +207,11 @@ func migratePreSealedSectors(presealsb string, repoPath string, mds dtypes.Metad
|
||||
}
|
||||
|
||||
func migratePreSealMeta(ctx context.Context, api lapi.FullNode, presealDir string, maddr address.Address, mds dtypes.MetadataDS) error {
|
||||
presealDir, err := homedir.Expand(presealDir)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("expanding preseal dir: %w", err)
|
||||
}
|
||||
|
||||
b, err := ioutil.ReadFile(filepath.Join(presealDir, "pre-seal-"+maddr.String()+".json"))
|
||||
if err != nil {
|
||||
return xerrors.Errorf("reading preseal metadata: %w", err)
|
||||
|
@ -1 +0,0 @@
|
||||
package sectorbuilder
|
@ -97,7 +97,7 @@ func (rspco *JsonRSPCO) rspco() RawSealPreCommitOutput {
|
||||
}
|
||||
|
||||
type SealRes struct {
|
||||
Err error
|
||||
Err string
|
||||
|
||||
Proof []byte
|
||||
Rspco JsonRSPCO
|
||||
@ -322,7 +322,11 @@ func (sb *SectorBuilder) ReadPieceFromSealedSector(pieceKey string) ([]byte, err
|
||||
func (sb *SectorBuilder) sealPreCommitRemote(call workerCall) (RawSealPreCommitOutput, error) {
|
||||
select {
|
||||
case ret := <-call.ret:
|
||||
return ret.Rspco.rspco(), ret.Err
|
||||
var err error
|
||||
if ret.Err != "" {
|
||||
err = xerrors.New(ret.Err)
|
||||
}
|
||||
return ret.Rspco.rspco(), err
|
||||
case <-sb.stopping:
|
||||
return RawSealPreCommitOutput{}, xerrors.New("sectorbuilder stopped")
|
||||
}
|
||||
@ -402,7 +406,10 @@ func (sb *SectorBuilder) SealPreCommit(sectorID uint64, ticket SealTicket, piece
|
||||
func (sb *SectorBuilder) sealCommitRemote(call workerCall) (proof []byte, err error) {
|
||||
select {
|
||||
case ret := <-call.ret:
|
||||
return ret.Proof, ret.Err
|
||||
if ret.Err != "" {
|
||||
err = xerrors.New(ret.Err)
|
||||
}
|
||||
return ret.Proof, err
|
||||
case <-sb.stopping:
|
||||
return nil, xerrors.New("sectorbuilder stopped")
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import (
|
||||
logging "github.com/ipfs/go-log"
|
||||
"github.com/ipfs/go-merkledag"
|
||||
peer "github.com/libp2p/go-libp2p-peer"
|
||||
"github.com/mitchellh/go-homedir"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/address"
|
||||
"github.com/filecoin-project/lotus/chain/gen"
|
||||
@ -72,18 +73,23 @@ func MakeGenesis(outFile, preseal string) func(bs dtypes.ChainBlockstore, w *wal
|
||||
return func(bs dtypes.ChainBlockstore, w *wallet.Wallet) modules.Genesis {
|
||||
return func() (*types.BlockHeader, error) {
|
||||
glog.Warn("Generating new random genesis block, note that this SHOULD NOT happen unless you are setting up new network")
|
||||
preseal, err := homedir.Expand(preseal)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("expanding preseals json path: %w", err)
|
||||
}
|
||||
|
||||
fdata, err := ioutil.ReadFile(preseal)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("reading preseals json: %w", err)
|
||||
}
|
||||
|
||||
var preseals map[string]genesis.GenesisMiner
|
||||
if err := json.Unmarshal(fdata, &preseals); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var preseal map[string]genesis.GenesisMiner
|
||||
if err := json.Unmarshal(fdata, &preseal); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
minerAddresses := make([]address.Address, 0, len(preseal))
|
||||
for s := range preseal {
|
||||
minerAddresses := make([]address.Address, 0, len(preseals))
|
||||
for s := range preseals {
|
||||
a, err := address.NewFromString(s)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -96,13 +102,13 @@ func MakeGenesis(outFile, preseal string) func(bs dtypes.ChainBlockstore, w *wal
|
||||
|
||||
gmc := &gen.GenMinerCfg{
|
||||
PeerIDs: []peer.ID{"peer ID 1"},
|
||||
PreSeals: preseal,
|
||||
PreSeals: preseals,
|
||||
MinerAddrs: minerAddresses,
|
||||
}
|
||||
|
||||
addrs := map[address.Address]types.BigInt{}
|
||||
|
||||
for _, miner := range preseal {
|
||||
for _, miner := range preseals {
|
||||
if _, err := w.Import(&miner.Key); err != nil {
|
||||
return nil, xerrors.Errorf("importing miner key: %w", err)
|
||||
}
|
||||
|
5
scripts/dev/drop-local-repos
Executable file
5
scripts/dev/drop-local-repos
Executable file
@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
set -o xtrace
|
||||
|
||||
rm -rf ~/.lotus ~/.lotusstorage/ ~/.genesis-sectors
|
8
scripts/dev/gen-daemon
Executable file
8
scripts/dev/gen-daemon
Executable file
@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
set -o xtrace
|
||||
|
||||
export TRUST_PARAMS=1
|
||||
|
||||
go run -tags=debug ./cmd/lotus-seed pre-seal
|
||||
go run -tags=debug ./cmd/lotus daemon --lotus-make-random-genesis=devel.gen --genesis-presealed-sectors=~/.genesis-sectors/pre-seal-t0101.json
|
7
scripts/dev/sminer-init
Executable file
7
scripts/dev/sminer-init
Executable file
@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
set -o xtrace
|
||||
|
||||
export TRUST_PARAMS=1
|
||||
|
||||
go run -tags=debug ./cmd/lotus-storage-miner init --actor=t0101 --genesis-miner --pre-sealed-sectors=~/.genesis-sectors
|
Loading…
Reference in New Issue
Block a user