Skip to content

Commit 5647250

Browse files
authored
avoid ChainNotify & update to newer interopnet (textileio#357)
* avoid notify in deals module Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com> * use lotus client directly Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com> * update bootstrap peers Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com> * lints Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com> * lint Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com> * use new lotus-devnet Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com> * unique tmp dir for test pkg since run in parallel Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com> * clean previous tmp dir Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
1 parent b585b89 commit 5647250

19 files changed

Lines changed: 140 additions & 66 deletions

File tree

chainsync/chainsync.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,15 @@ import (
44
"context"
55
"fmt"
66

7+
"github.com/filecoin-project/lotus/api/apistruct"
78
"github.com/filecoin-project/lotus/chain/types"
8-
"github.com/textileio/lotus-client/api/apistruct"
9-
"github.com/textileio/lotus-client/chain/store"
9+
)
10+
11+
const (
12+
hcApply = "apply"
13+
// For completeness:
14+
// hcRevert = "revert"
15+
// hcCurrent = "current"
1016
)
1117

1218
// ChainSync provides methods to resolve chain syncing situations
@@ -31,7 +37,7 @@ func (cs *ChainSync) Precedes(ctx context.Context, from, to types.TipSetKey) (bo
3137
if len(fpath) == 0 {
3238
return true, nil
3339
}
34-
norevert := fpath[0].Type == store.HCApply
40+
norevert := fpath[0].Type == hcApply
3541
return norevert, nil
3642
}
3743

@@ -56,7 +62,7 @@ func ResolveBase(ctx context.Context, api *apistruct.FullNodeStruct, left *types
5662

5763
var base *types.TipSetKey
5864
for _, ts := range fpath {
59-
if ts.Type == store.HCApply {
65+
if ts.Type == hcApply {
6066
if base == nil {
6167
b := types.NewTipSetKey(ts.Val.Blocks()[0].Parents...)
6268
base = &b

deals/deals.go

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ import (
1313

1414
"github.com/filecoin-project/go-address"
1515
"github.com/filecoin-project/go-fil-markets/storagemarket"
16+
"github.com/filecoin-project/lotus/api"
17+
"github.com/filecoin-project/lotus/api/apistruct"
1618
"github.com/filecoin-project/lotus/chain/types"
1719
"github.com/ipfs/go-cid"
1820
logging "github.com/ipfs/go-log/v2"
19-
"github.com/textileio/lotus-client/api"
20-
"github.com/textileio/lotus-client/api/apistruct"
21+
"github.com/textileio/powergate/util"
2122
)
2223

2324
const (
@@ -184,22 +185,14 @@ func (m *Module) Watch(ctx context.Context, proposals []cid.Cid) (<-chan DealInf
184185
return nil, fmt.Errorf("proposals list can't be empty")
185186
}
186187
ch := make(chan DealInfo)
187-
w, err := m.api.ChainNotify(ctx)
188-
if err != nil {
189-
return nil, fmt.Errorf("listening to chain changes: %s", err)
190-
}
191188
go func() {
192189
defer close(ch)
193190
currentState := make(map[cid.Cid]*api.DealInfo)
194191
for {
195192
select {
196193
case <-ctx.Done():
197194
return
198-
case _, ok := <-w:
199-
if !ok {
200-
log.Errorf("chain notify channel was closed by lotus node")
201-
return
202-
}
195+
case <-time.After(util.AvgBlockTime):
203196
if err := pushNewChanges(ctx, m.api, currentState, proposals, ch); err != nil {
204197
log.Errorf("pushing new proposal states: %s", err)
205198
}

deals/deals_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,22 @@ import (
1212
"time"
1313

1414
"github.com/filecoin-project/go-fil-markets/storagemarket"
15+
"github.com/filecoin-project/lotus/api/apistruct"
1516
"github.com/filecoin-project/lotus/chain/types"
1617
"github.com/ipfs/go-cid"
1718
logging "github.com/ipfs/go-log/v2"
1819
"github.com/stretchr/testify/require"
19-
"github.com/textileio/lotus-client/api/apistruct"
2020
"github.com/textileio/powergate/tests"
2121
)
2222

2323
const (
24-
tmpDir = "/tmp/powergate"
24+
tmpDir = "/tmp/powergate/dealstest"
2525
)
2626

2727
func TestMain(m *testing.M) {
28+
if err := os.RemoveAll(tmpDir); err != nil {
29+
panic(err)
30+
}
2831
if _, err := os.Stat(tmpDir); os.IsNotExist(err) {
2932
if err := os.Mkdir(tmpDir, os.ModePerm); err != nil {
3033
panic(err)

docker/docker-compose-embedded.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ services:
3232
- 5001:5001
3333

3434
lotus:
35-
image: textile/lotus-devnet:sha-c755791
35+
image: textile/lotus-devnet:sha-3eefd29
3636
ports:
3737
- 7777:7777
3838
environment:

fchost/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import (
99

1010
var (
1111
addrs = []string{
12-
"/dns4/t01000.miner.interopnet.kittyhawk.wtf/tcp/1347/p2p/12D3KooWNjqGTNZ592wG5DmX7Rbmb76V3NHMdZMqjqPJ1xiax7w6",
13-
"/ip4/54.186.82.90/tcp/1347/p2p/12D3KooWGf4ggd3cdZJKZPHkgSe8Lxf4MDsKhVC7npRGXgsPP4fz",
12+
"/dns4/t01000.miner.interopnet.kittyhawk.wtf/tcp/1347/p2p/12D3KooWEbScoeDSJtaEjXEwqMHYBghkrmct487mm4H3pG2fie3t",
13+
"/ip4/54.186.82.90/tcp/1347/p2p/12D3KooWKqBJPXy1Ei7Ww6o4BuXU3bs7mANi4VKbPiGqc1CRX1A2",
1414
}
1515
)
1616

fchost/fchost.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"github.com/libp2p/go-libp2p-core/host"
1111
"github.com/libp2p/go-libp2p-core/peer"
1212
dht "github.com/libp2p/go-libp2p-kad-dht"
13-
dhtopts "github.com/libp2p/go-libp2p-kad-dht/opts"
1413
routedhost "github.com/libp2p/go-libp2p/p2p/host/routed"
1514
"github.com/libp2p/go-libp2p/p2p/protocol/ping"
1615
"github.com/multiformats/go-multiaddr"
@@ -36,7 +35,7 @@ func New() (*FilecoinHost, error) {
3635
return nil, err
3736
}
3837

39-
dht, err := dht.New(ctx, h, dhtopts.Protocols("/fil/kad/interop"))
38+
dht, err := dht.New(ctx, h, dht.ProtocolPrefix("/fil/kad/interop"))
4039
if err != nil {
4140
return nil, err
4241
}

ffs/integrationtest/integration_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"time"
1414

1515
"github.com/filecoin-project/go-address"
16+
"github.com/filecoin-project/lotus/api/apistruct"
1617
"github.com/ipfs/go-cid"
1718
"github.com/ipfs/go-datastore"
1819
ipfsfiles "github.com/ipfs/go-ipfs-files"
@@ -21,7 +22,6 @@ import (
2122
"github.com/ipfs/interface-go-ipfs-core/options"
2223
"github.com/ory/dockertest"
2324
"github.com/stretchr/testify/require"
24-
"github.com/textileio/lotus-client/api/apistruct"
2525
"github.com/textileio/powergate/deals"
2626
"github.com/textileio/powergate/ffs"
2727
"github.com/textileio/powergate/ffs/api"
@@ -42,7 +42,7 @@ import (
4242
)
4343

4444
const (
45-
tmpDir = "/tmp/powergate"
45+
tmpDir = "/tmp/powergate/integrationtest"
4646
)
4747

4848
func TestMain(m *testing.M) {

go.mod

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ require (
1515
github.com/docker/go-connections v0.4.0 // indirect
1616
github.com/filecoin-project/go-address v0.0.2-0.20200218010043-eb9bb40ed5be
1717
github.com/filecoin-project/go-fil-markets v0.0.0-20200415011556-4378bd41b91f
18-
github.com/filecoin-project/lotus v0.2.11-0.20200423065310-a99875feaca9
19-
github.com/filecoin-project/specs-actors v0.0.0-20200421235624-312ac81e2aa4
18+
github.com/filecoin-project/lotus v0.2.11-0.20200425000157-1bfa2311d693
19+
github.com/filecoin-project/specs-actors v1.0.1-0.20200424174946-11410d0bbcaf
2020
github.com/gin-contrib/location v0.0.1
2121
github.com/gin-contrib/static v0.0.0-20191128031702-f81c604d8ac2
2222
github.com/gin-gonic/gin v1.6.2
@@ -32,18 +32,18 @@ require (
3232
github.com/ipfs/go-car v0.0.4-0.20200304012825-b6769248bfef
3333
github.com/ipfs/go-cid v0.0.5
3434
github.com/ipfs/go-datastore v0.4.4
35-
github.com/ipfs/go-ds-badger2 v0.0.0-20200211201106-609c9d2a39c7
35+
github.com/ipfs/go-ds-badger2 v0.1.0
3636
github.com/ipfs/go-ipfs-files v0.0.8
3737
github.com/ipfs/go-ipfs-http-client v0.0.6-0.20200228220229-2e259051cd8b
3838
github.com/ipfs/go-ipld-cbor v0.0.5-0.20200204214505-252690b78669
3939
github.com/ipfs/go-ipld-format v0.0.2
40-
github.com/ipfs/go-log/v2 v2.0.4
40+
github.com/ipfs/go-log/v2 v2.0.5
4141
github.com/ipfs/interface-go-ipfs-core v0.2.6
4242
github.com/jessevdk/go-assets v0.0.0-20160921144138-4f4301a06e15
4343
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
44-
github.com/libp2p/go-libp2p v0.6.1
44+
github.com/libp2p/go-libp2p v0.8.1
4545
github.com/libp2p/go-libp2p-core v0.5.1
46-
github.com/libp2p/go-libp2p-kad-dht v0.5.0
46+
github.com/libp2p/go-libp2p-kad-dht v0.7.6
4747
github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381
4848
github.com/manifoldco/promptui v0.7.0
4949
github.com/mattn/go-runewidth v0.0.8 // indirect
@@ -61,7 +61,6 @@ require (
6161
github.com/spf13/pflag v1.0.5
6262
github.com/spf13/viper v1.6.2
6363
github.com/stretchr/testify v1.5.1
64-
github.com/textileio/lotus-client v0.0.0-20200423155630-a78508702421
6564
go.opencensus.io v0.22.3
6665
google.golang.org/grpc v1.28.1
6766
)

0 commit comments

Comments
 (0)