broken mining and deal sealing
This commit is contained in:
parent
cca568112d
commit
e8f037cac8
@ -10,7 +10,6 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/davecgh/go-spew/spew"
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/go-fil-markets/storagemarket"
|
"github.com/filecoin-project/go-fil-markets/storagemarket"
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
@ -64,7 +63,7 @@ func runBaselineBootstrapper(t *TestEnvironment) error {
|
|||||||
|
|
||||||
func runBaselineMiner(t *TestEnvironment) error {
|
func runBaselineMiner(t *TestEnvironment) error {
|
||||||
t.RecordMessage("running miner")
|
t.RecordMessage("running miner")
|
||||||
_, err := prepareMiner(t)
|
miner, err := prepareMiner(t)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -78,24 +77,23 @@ func runBaselineMiner(t *TestEnvironment) error {
|
|||||||
t.RecordMessage("got %v client addrs", len(addrs))
|
t.RecordMessage("got %v client addrs", len(addrs))
|
||||||
|
|
||||||
// mine / stop mining
|
// mine / stop mining
|
||||||
//mine := true
|
mine := true
|
||||||
//done := make(chan struct{})
|
done := make(chan struct{})
|
||||||
//go func() {
|
go func() {
|
||||||
//defer close(done)
|
defer close(done)
|
||||||
//for mine {
|
for mine {
|
||||||
//time.Sleep(blocktime)
|
time.Sleep(7 * time.Second)
|
||||||
//if err := sn[0].MineOne(ctx, func(bool) {}); err != nil {
|
t.RecordMessage("mine one block")
|
||||||
//t.Error(err)
|
if err := miner.MineOne(ctx, func(bool) {}); err != nil {
|
||||||
//}
|
panic(err)
|
||||||
//}
|
}
|
||||||
//}()
|
}
|
||||||
//makeDeal(t, ctx, 6, client, miner, carExport)
|
}()
|
||||||
//mine = false
|
|
||||||
//fmt.Println("shutting down mining")
|
|
||||||
//<-done
|
|
||||||
|
|
||||||
// TODO wait a bit for network to bootstrap
|
time.Sleep(30 * time.Second)
|
||||||
// TODO just wait until completion of test, serving requests -- the client does all the job
|
mine = false
|
||||||
|
fmt.Println("shutting down mining")
|
||||||
|
<-done
|
||||||
|
|
||||||
t.SyncClient.MustSignalAndWait(ctx, stateDone, t.TestInstanceCount)
|
t.SyncClient.MustSignalAndWait(ctx, stateDone, t.TestInstanceCount)
|
||||||
return nil
|
return nil
|
||||||
@ -124,28 +122,29 @@ func runBaselineClient(t *TestEnvironment) error {
|
|||||||
|
|
||||||
t.RecordMessage("client connected to miner")
|
t.RecordMessage("client connected to miner")
|
||||||
|
|
||||||
// generate a number of random "files" and publish them to one or more miners
|
// generate random data
|
||||||
data := make([]byte, 1600)
|
data := make([]byte, 1600)
|
||||||
rand.New(rand.NewSource(time.Now().UnixNano())).Read(data)
|
rand.New(rand.NewSource(time.Now().UnixNano())).Read(data)
|
||||||
|
|
||||||
r := bytes.NewReader(data)
|
r := bytes.NewReader(data)
|
||||||
fcid, err := client.ClientImportLocal(ctx, r)
|
fcid, err := client.ClientImportLocal(ctx, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
t.RecordMessage("file cid: %s", fcid)
|
t.RecordMessage("file cid: %s", fcid)
|
||||||
|
|
||||||
// start deal
|
// start deal
|
||||||
deal := startDeal(ctx, addrs[0].ActorAddr, client, fcid)
|
deal := startDeal(ctx, addrs[0].ActorAddr, client, fcid)
|
||||||
spew.Dump(deal)
|
t.RecordMessage("started deal: %s", deal)
|
||||||
|
|
||||||
// TODO: this sleep is only necessary because deals don't immediately get logged in the dealstore, we should fix this
|
// TODO: this sleep is only necessary because deals don't immediately get logged in the dealstore, we should fix this
|
||||||
time.Sleep(time.Second)
|
time.Sleep(3 * time.Second)
|
||||||
|
|
||||||
|
// wait for deal to be sealed
|
||||||
waitDealSealed(ctx, client, deal)
|
waitDealSealed(ctx, client, deal)
|
||||||
|
|
||||||
carExport := true
|
carExport := true
|
||||||
|
|
||||||
|
// try to retrieve fcid
|
||||||
testRetrieval(ctx, err, client, fcid, carExport, data)
|
testRetrieval(ctx, err, client, fcid, carExport, data)
|
||||||
|
|
||||||
// TODO broadcast published content CIDs to other clients
|
// TODO broadcast published content CIDs to other clients
|
||||||
|
@ -32,6 +32,7 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/chain/wallet"
|
"github.com/filecoin-project/lotus/chain/wallet"
|
||||||
"github.com/filecoin-project/lotus/cmd/lotus-seed/seed"
|
"github.com/filecoin-project/lotus/cmd/lotus-seed/seed"
|
||||||
"github.com/filecoin-project/lotus/genesis"
|
"github.com/filecoin-project/lotus/genesis"
|
||||||
|
"github.com/filecoin-project/lotus/miner"
|
||||||
"github.com/filecoin-project/lotus/node"
|
"github.com/filecoin-project/lotus/node"
|
||||||
"github.com/filecoin-project/lotus/node/config"
|
"github.com/filecoin-project/lotus/node/config"
|
||||||
"github.com/filecoin-project/lotus/node/modules"
|
"github.com/filecoin-project/lotus/node/modules"
|
||||||
@ -72,6 +73,7 @@ type Node struct {
|
|||||||
fullApi api.FullNode
|
fullApi api.FullNode
|
||||||
minerApi api.StorageMiner
|
minerApi api.StorageMiner
|
||||||
stop node.StopFunc
|
stop node.StopFunc
|
||||||
|
MineOne func(context.Context, func(bool)) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type InitialBalanceMsg struct {
|
type InitialBalanceMsg struct {
|
||||||
@ -354,11 +356,13 @@ func prepareMiner(t *TestEnvironment) (*Node, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mineBlock := make(chan func(bool))
|
||||||
stop2, err := node.New(context.Background(),
|
stop2, err := node.New(context.Background(),
|
||||||
node.StorageMiner(&n.minerApi),
|
node.StorageMiner(&n.minerApi),
|
||||||
node.Online(),
|
node.Online(),
|
||||||
node.Repo(minerRepo),
|
node.Repo(minerRepo),
|
||||||
node.Override(new(api.FullNode), n.fullApi),
|
node.Override(new(api.FullNode), n.fullApi),
|
||||||
|
node.Override(new(*miner.Miner), miner.NewTestMiner(mineBlock, minerAddr)),
|
||||||
withMinerListenAddress(minerIP),
|
withMinerListenAddress(minerIP),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -375,6 +379,21 @@ func prepareMiner(t *TestEnvironment) (*Node, error) {
|
|||||||
return err1
|
return err1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*// Bootstrap with full node
|
||||||
|
remoteAddrs, err := tnd.NetAddrsListen(ctx)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
err = minerapi.NetConnect(ctx, remoteAddrs)
|
||||||
|
require.NoError(t, err)*/
|
||||||
|
n.MineOne = func(ctx context.Context, cb func(bool)) error {
|
||||||
|
select {
|
||||||
|
case mineBlock <- cb:
|
||||||
|
return nil
|
||||||
|
case <-ctx.Done():
|
||||||
|
return ctx.Err()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// add local storage for presealed sectors
|
// add local storage for presealed sectors
|
||||||
err = n.minerApi.StorageAddLocal(ctx, presealDir)
|
err = n.minerApi.StorageAddLocal(ctx, presealDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user