Remove Ensemble dep on Curio
This commit is contained in:
parent
f97036c1b0
commit
76459fc226
@ -30,8 +30,8 @@ import (
|
|||||||
miner2 "github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
miner2 "github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/lotus/cli/spcli"
|
"github.com/filecoin-project/lotus/cli/spcli"
|
||||||
"github.com/filecoin-project/lotus/cmd/curio/rpc"
|
"github.com/filecoin-project/lotus/curiosrc/cmd/curio/rpc"
|
||||||
"github.com/filecoin-project/lotus/cmd/curio/tasks"
|
"github.com/filecoin-project/lotus/curiosrc/cmd/curio/tasks"
|
||||||
"github.com/filecoin-project/lotus/curiosrc/deps"
|
"github.com/filecoin-project/lotus/curiosrc/deps"
|
||||||
"github.com/filecoin-project/lotus/curiosrc/ffiselect"
|
"github.com/filecoin-project/lotus/curiosrc/ffiselect"
|
||||||
"github.com/filecoin-project/lotus/curiosrc/market/lmrpc"
|
"github.com/filecoin-project/lotus/curiosrc/market/lmrpc"
|
@ -13,15 +13,6 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
|
||||||
"github.com/ipfs/go-datastore"
|
|
||||||
"github.com/ipfs/go-datastore/namespace"
|
|
||||||
libp2pcrypto "github.com/libp2p/go-libp2p/core/crypto"
|
|
||||||
"github.com/libp2p/go-libp2p/core/peer"
|
|
||||||
mocknet "github.com/libp2p/go-libp2p/p2p/net/mock"
|
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
"github.com/urfave/cli/v2"
|
|
||||||
|
|
||||||
"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-state-types/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
@ -32,6 +23,13 @@ import (
|
|||||||
"github.com/filecoin-project/go-statestore"
|
"github.com/filecoin-project/go-statestore"
|
||||||
miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner"
|
miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner"
|
||||||
power3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/power"
|
power3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/power"
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/ipfs/go-datastore"
|
||||||
|
"github.com/ipfs/go-datastore/namespace"
|
||||||
|
libp2pcrypto "github.com/libp2p/go-libp2p/core/crypto"
|
||||||
|
"github.com/libp2p/go-libp2p/core/peer"
|
||||||
|
mocknet "github.com/libp2p/go-libp2p/p2p/net/mock"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/api/v1api"
|
"github.com/filecoin-project/lotus/api/v1api"
|
||||||
@ -46,11 +44,8 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/chain/stmgr"
|
"github.com/filecoin-project/lotus/chain/stmgr"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/lotus/chain/wallet/key"
|
"github.com/filecoin-project/lotus/chain/wallet/key"
|
||||||
"github.com/filecoin-project/lotus/cmd/curio/rpc"
|
|
||||||
"github.com/filecoin-project/lotus/cmd/curio/tasks"
|
|
||||||
"github.com/filecoin-project/lotus/cmd/lotus-seed/seed"
|
"github.com/filecoin-project/lotus/cmd/lotus-seed/seed"
|
||||||
"github.com/filecoin-project/lotus/cmd/lotus-worker/sealworker"
|
"github.com/filecoin-project/lotus/cmd/lotus-worker/sealworker"
|
||||||
"github.com/filecoin-project/lotus/curiosrc/deps"
|
|
||||||
"github.com/filecoin-project/lotus/gateway"
|
"github.com/filecoin-project/lotus/gateway"
|
||||||
"github.com/filecoin-project/lotus/genesis"
|
"github.com/filecoin-project/lotus/genesis"
|
||||||
"github.com/filecoin-project/lotus/lib/harmony/harmonydb"
|
"github.com/filecoin-project/lotus/lib/harmony/harmonydb"
|
||||||
@ -124,17 +119,15 @@ type Ensemble struct {
|
|||||||
options *ensembleOpts
|
options *ensembleOpts
|
||||||
|
|
||||||
inactive struct {
|
inactive struct {
|
||||||
fullnodes []*TestFullNode
|
fullnodes []*TestFullNode
|
||||||
providernodes []*TestCurioNode
|
miners []*TestMiner
|
||||||
miners []*TestMiner
|
workers []*TestWorker
|
||||||
workers []*TestWorker
|
|
||||||
}
|
}
|
||||||
active struct {
|
active struct {
|
||||||
fullnodes []*TestFullNode
|
fullnodes []*TestFullNode
|
||||||
providernodes []*TestCurioNode
|
miners []*TestMiner
|
||||||
miners []*TestMiner
|
workers []*TestWorker
|
||||||
workers []*TestWorker
|
bms map[*TestMiner]*BlockMiner
|
||||||
bms map[*TestMiner]*BlockMiner
|
|
||||||
}
|
}
|
||||||
genesis struct {
|
genesis struct {
|
||||||
version network.Version
|
version network.Version
|
||||||
@ -227,20 +220,6 @@ func (n *Ensemble) FullNode(full *TestFullNode, opts ...NodeOpt) *Ensemble {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
// FullNode enrolls a new Curio node.
|
|
||||||
func (n *Ensemble) Curio(cu *TestCurioNode, opts ...NodeOpt) *Ensemble {
|
|
||||||
options := DefaultNodeOpts
|
|
||||||
for _, o := range opts {
|
|
||||||
err := o(&options)
|
|
||||||
require.NoError(n.t, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
*cu = TestCurioNode{t: n.t, options: options, Deps: &deps.Deps{}}
|
|
||||||
|
|
||||||
n.inactive.providernodes = append(n.inactive.providernodes, cu)
|
|
||||||
return n
|
|
||||||
}
|
|
||||||
|
|
||||||
// Miner enrolls a new miner, using the provided full node for chain
|
// Miner enrolls a new miner, using the provided full node for chain
|
||||||
// interactions.
|
// interactions.
|
||||||
func (n *Ensemble) MinerEnroll(minerNode *TestMiner, full *TestFullNode, opts ...NodeOpt) *Ensemble {
|
func (n *Ensemble) MinerEnroll(minerNode *TestMiner, full *TestFullNode, opts ...NodeOpt) *Ensemble {
|
||||||
@ -902,28 +881,6 @@ func (n *Ensemble) Start() *Ensemble {
|
|||||||
// to active, so clear the slice.
|
// to active, so clear the slice.
|
||||||
n.inactive.workers = n.inactive.workers[:0]
|
n.inactive.workers = n.inactive.workers[:0]
|
||||||
|
|
||||||
for _, p := range n.inactive.providernodes {
|
|
||||||
|
|
||||||
// TODO setup config with options
|
|
||||||
err := p.Deps.PopulateRemainingDeps(context.Background(), &cli.Context{}, false)
|
|
||||||
require.NoError(n.t, err)
|
|
||||||
|
|
||||||
shutdownChan := make(chan struct{})
|
|
||||||
taskEngine, err := tasks.StartTasks(ctx, p.Deps)
|
|
||||||
if err != nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
defer taskEngine.GracefullyTerminate()
|
|
||||||
|
|
||||||
err = rpc.ListenAndServe(ctx, p.Deps, shutdownChan) // Monitor for shutdown.
|
|
||||||
require.NoError(n.t, err)
|
|
||||||
finishCh := node.MonitorShutdown(shutdownChan) //node.ShutdownHandler{Component: "rpc server", StopFunc: rpcStopper},
|
|
||||||
//node.ShutdownHandler{Component: "provider", StopFunc: stop},
|
|
||||||
|
|
||||||
<-finishCh
|
|
||||||
|
|
||||||
n.active.providernodes = append(n.active.providernodes, p)
|
|
||||||
}
|
|
||||||
// ---------------------
|
// ---------------------
|
||||||
// MISC
|
// MISC
|
||||||
// ---------------------
|
// ---------------------
|
||||||
|
@ -101,21 +101,6 @@ func EnsembleOneTwo(t *testing.T, opts ...interface{}) (*TestFullNode, *TestMine
|
|||||||
return &full, &one, &two, ens
|
return &full, &one, &two, ens
|
||||||
}
|
}
|
||||||
|
|
||||||
// EnsembleProvider creates and starts an Ensemble with a single full node and a single Curio.
|
|
||||||
// It does not interconnect nodes nor does it begin mining.
|
|
||||||
func EnsembleProvider(t *testing.T, opts ...interface{}) (*TestFullNode, *TestCurioNode, *Ensemble) {
|
|
||||||
opts = append(opts, WithAllSubsystems())
|
|
||||||
|
|
||||||
eopts, nopts := siftOptions(t, opts)
|
|
||||||
|
|
||||||
var (
|
|
||||||
full TestFullNode
|
|
||||||
provider TestCurioNode
|
|
||||||
)
|
|
||||||
ens := NewEnsemble(t, eopts...).FullNode(&full, nopts...).Curio(&provider, nopts...).Start()
|
|
||||||
return &full, &provider, ens
|
|
||||||
}
|
|
||||||
|
|
||||||
func siftOptions(t *testing.T, opts []interface{}) (eopts []EnsembleOpt, nopts []NodeOpt) {
|
func siftOptions(t *testing.T, opts []interface{}) (eopts []EnsembleOpt, nopts []NodeOpt) {
|
||||||
for _, v := range opts {
|
for _, v := range opts {
|
||||||
switch o := v.(type) {
|
switch o := v.(type) {
|
||||||
|
@ -22,7 +22,6 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/lotus/chain/wallet/key"
|
"github.com/filecoin-project/lotus/chain/wallet/key"
|
||||||
cliutil "github.com/filecoin-project/lotus/cli/util"
|
cliutil "github.com/filecoin-project/lotus/cli/util"
|
||||||
"github.com/filecoin-project/lotus/curiosrc/deps"
|
|
||||||
"github.com/filecoin-project/lotus/gateway"
|
"github.com/filecoin-project/lotus/gateway"
|
||||||
"github.com/filecoin-project/lotus/node"
|
"github.com/filecoin-project/lotus/node"
|
||||||
)
|
)
|
||||||
@ -55,17 +54,6 @@ type TestFullNode struct {
|
|||||||
options nodeOpts
|
options nodeOpts
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestCurioNode represents a Curio node enrolled in an Ensemble.
|
|
||||||
type TestCurioNode struct {
|
|
||||||
v1api.CurioStruct
|
|
||||||
|
|
||||||
t *testing.T
|
|
||||||
|
|
||||||
*deps.Deps
|
|
||||||
|
|
||||||
options nodeOpts
|
|
||||||
}
|
|
||||||
|
|
||||||
func MergeFullNodes(fullNodes []*TestFullNode) *TestFullNode {
|
func MergeFullNodes(fullNodes []*TestFullNode) *TestFullNode {
|
||||||
var wrappedFullNode TestFullNode
|
var wrappedFullNode TestFullNode
|
||||||
var fns api.FullNodeStruct
|
var fns api.FullNodeStruct
|
||||||
|
Loading…
Reference in New Issue
Block a user